-
Write a JavaScript function that will find the largest of five numbers. Display an alert box to show the result. Sample numbers : -5, -2, -6, 0, -1 Output : 0
-
Write a JavaScript conditional statement to sort three numbers. Display an alert box to show the result. Sample numbers : 0, -1, 4 Output : 4, 0, -1
-
Write a JavaScript function to get the first element of an array. Passing a parameter 'n' will return the first 'n' elements of the array. Test Data :
console.log(first([7, 9, 0, -2]));
console.log(first([],3));
console.log(first([7, 9, 0, -2],3));
console.log(first([7, 9, 0, -2],6));
console.log(first([7, 9, 0, -2],-3));
Expected Output :
7
[]
[7, 9, 0]
[7, 9, 0, -2]
-
Write a simple JavaScript program to join all elements of the following array into a string. Sample array :
myColor = ["Red", "Green", "White", "Black"];
Expected Output :"Red,Green,White,Black"
-
Write a JavaScript program which accept a number as input and insert dashes (-) between each two even numbers. For example if you accept 025468 the output should be 0-254-6-8.
-
Write a JavaScript program to find the most frequent item of an array. Sample array :
var arr1=[3, 'a', 'a', 'a', 2, 3, 'a', 3, 'a', 2, 4, 9, 3];
Sample Output : a ( 5 times )