CSS Programming Exercise On Unit-II.5ee4fa6
CSS Programming Exercise On Unit-II.5ee4fa6
1. Define a function called multiplyFive which accepts a number and returns that number
multiplied by 5.
6. Write a JavaScript function that accepts a number as a parameter and check the number is
prime or not.
1. Write a JavaScript function to split a string and convert it into an array of words.
2. Write a JavaScript function to extract a specified number of characters from a string.
3. Write a JavaScript function to convert a string in abbreviated form.
Test Data :
input string - "Robin Singh"
Output - "Robin S."
4. Write a JavaScript function to display output as below.
Test Data :
input – “Robin Singh from USA."
Output - "robin-singh-from-usa"
5. Write a JavaScript function to capitalize the first letter of a string.
Test Data :
input - 'js string exercises'
Output - "Js string exercises"
6. Write a JavaScript function to capitalize the first letter of each word in a string.
Test Data :
Input - 'js string exercises'
Output - "Js String Exercises"
7. Get an input from the user and determine whether the string is palindrome.
Palindrome is a word, phrase, or sequence that reads the same backwards as forwards,
8. Get an input from the user and strip out all the vowels.
The letters A, E, I, O, and U are called vowels.
9. Get an input from the user and convert it into Capitalize format.
eg. ‘london’ should return “London”
10. Write a JavaScript function to insert a string within a string at a particular position.
Test Data :
Input - "We are doing some exercises."
Output - "We are doing some JavaScript exercises."
11. Write a JavaScript function to get the first n elements of an array. Passing a parameter 'n'
will return the first 'n' elements of the array.
Test Data :
Input - ([7, 9, 0, -2],3)
Output- 7,9,0
12. Write a JavaScript function to get the last n elements of an array. Passing a parameter 'n'
will return the last 'n' elements of the array.
Test Data :
Input - ([7, 9, 0, -2],3));
Output - [9, 0, -2]
13. 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"
"Red-Green-White-Black"
"Red+Green+White+Black"
14. 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 )
15. Write a JavaScript program to compute the sum and product of an array of integers.
16. Write a JavaScript program to add items in an blank array and display the items.
Sample Screen :
20. Write a JavaScript function which will take an array of numbers stored and find the
second lowest and second greatest numbers, respectively.