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

Javascript Set A

The document contains examples of JavaScript code snippets that perform tasks like printing prime numbers, calculating sums of odd digits in a number, checking dates and printing messages, calculating age from a birth date, counting vowels in a string, replacing spaces and digits in a sentence, and using string functions like indexOf, lastIndexOf, search and replace.

Uploaded by

emumono8612
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Javascript Set A

The document contains examples of JavaScript code snippets that perform tasks like printing prime numbers, calculating sums of odd digits in a number, checking dates and printing messages, calculating age from a birth date, counting vowels in a string, replacing spaces and digits in a sentence, and using string functions like indexOf, lastIndexOf, search and replace.

Uploaded by

emumono8612
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

1. Write a JavaScript program to print prime numbers between 1 to 100.

Output :

2. Write a java script code to accept a number from user and write a function to calculate sum of all
odd digits of that number.
Output :

3. Write a JavaScript code to accept date from the user. If date entered by the user is 1st January
then Print―Happy New Year, if 25th December then Print―Merry Christmas, if 14th January then
Print―Happy Makarsankranti, otherwise Print―Have a Good Day message.
Output :

4. Write a JavaScript code to accept birth-date and print the age of a user.
5. Write a java script program to accept a string from user and display the count of vowel characters
from that string.

Output :
6. Write a java script code to accept a sentence from the user and alters it as follows: Every space
should be replaced by ‘#’ and digits should be replaced by ‘$’.

Output :
7. Write a JavaScript function to perform following string functions: indexof, lastindexof, search and
replace.

Output :

You might also like