0% found this document useful (0 votes)
7 views

CSS Programming Exercise On Unit-II.5ee4fa6

Uploaded by

yashbirari29
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

CSS Programming Exercise On Unit-II.5ee4fa6

Uploaded by

yashbirari29
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CSS Programming Exercise - II

Exercise on Function in JavaScript

1. Define a function called multiplyFive which accepts a number and returns that number
multiplied by 5.

2. Create function called celsiusToFahrenheit and fahrenheitToCelsius for converting


temperature.

3. Write a JavaScript functions to calculate area and circumference of a circle.

4. Write a JavaScript function that reverse a number.

5. Write a JavaScript function that will display sum of digits of a number.

6. Write a JavaScript function that accepts a number as a parameter and check the number is
prime or not.

Exercise on Array and String in JavaScript

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,

Examples of palindrome words “madam”, “level”, “radar”, “noon” and “malayalam”.

8. Get an input from the user and strip out all the vowels.
The letters A, E, I, O, and U are called vowels.

eg. “Javascript” should return “Jvscrpt”

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 :

17. Find the leap years in a given range of years.


18. There are two arrays with individual values, write a JavaScript program to compute the
sum of each individual index value from the given arrays.
Sample array :
array1 = [1,0,2,3,4];
array2 = [3,5,6,7,8,13];
Expected Output :
[4, 5, 8, 10, 12, 13]
19. Write a JavaScript function to display largest number in a array of integers.

20. Write a JavaScript function which will take an array of numbers stored and find the
second lowest and second greatest numbers, respectively.

Sample array : [1,2,3,4,5]


Expected Output : 2,4

You might also like