JSExam
JSExam
1. Write a function that takes three numbers as arguments and returns the
largest number. For example: getLargest( 4, 20, 40 ) returns 40.
Only if else allowed. Don’t use Math.max
2. Write a function that takes a string and a character which is not an alphabet
and returns an array of all words that start with that character. Don't worry
about upper case or lower case character. For example: get_words( "I see
oranges in the orchard", "o") will return ["oranges","orchard"] get_words("Hi
my name is Henry") will return ["Hi", "Henry"]
Your function will check if array has atleast ‘n’ number of items. If not it
returns the same array. If it has enough items it removes those many items and
returns the smaller array after removing.
4. Write a function that takes two strings, and returns the string which has
more words in it? Remember not alphabets. Words.
For example : largest(“This is the larger string in this case”, “I am another
string”) will return “This is the larger string in this case” because it has 8
words in it compared to 4.
6. Create a paragraph with click event listener. On clicking the paragraph toggle
the color between red and green depending on how many times it has been
clicked. If number of clicks on the paragraph are multiple of 3 then make it
red otherwise make it green.
7. Write a program that prints the numbers from 10 to 60 including 10 and 60.
But for multiples of three print “Multiple of 3” instead of the number and for the
multiples of five print “Multiple of 5”. For numbers which are multiples of both three
and five print “Both”. If it’s not multiple of 3 or 5 just print the number.
Example:-
“Multiple of 5”
11
“Multiple of 3”
13
14
“Both”
16…. and so on...
8. Write a function that takes an array of strings and removes the strings that
contain a number in them and returns the new array ( not the reference ).