Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Exercises:
- JS Functions
- 1. Write a JavaScript function that returns a passed string with letters in alphabetical order. Go to the editor
- Example string : 'webmaster'
- Expected Output : 'abeemrstw'
- Assume punctuation and numbers symbols are not included in the passed string.
- 2. Write a JavaScript function that accepts a string as a parameter and converts the first letter of each word of the string in upper case. Go to the editor
- Example string : 'the quick brown fox'
- Expected Output : 'The Quick Brown Fox '
- 3. Write a JavaScript function that accepts a string as a parameter and find the longest word within the string. Go to the editor
- Example string : 'Web Development Tutorial'
- Expected Output : 'Development'
- 4. Write a JavaScript function that accepts a string as a parameter and counts the number of vowels within the string. Go to the editor
- Note : As the letter 'y' can be regarded as both a vowel and a consonant, we do not count 'y' as vowel here.
- Example string : 'The quick brown fox'
- Expected Output : 5
- 5. Write a JavaScript function that accepts a number as a parameter and check the number is prime or not. Go to the editor
- Note : A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.
- JS Objects
- 6.
- Write a JavaScript program to display the reading status (i.e. display book name, author name and reading status) of the following books. Go to the editor
- var library = [
- {
- author: 'Bill Gates',
- title: 'The Road Ahead',
- readingStatus: true
- },
- {
- author: 'Steve Jobs',
- title: 'Walter Isaacson',
- readingStatus: true
- },
- {
- author: 'Suzanne Collins',
- title: 'Mockingjay: The Final Book of The Hunger Games',
- readingStatus: false
- }];
- Validation
- 1. Write a JavaScript function to validate whether a given value type is boolean or not.
- 2. Write a JavaScript function to validate whether a given value type is NaN or not.
- 3. Write a JavaScript function to validate whether a given value type is null or not.
- 4. Write a JavaScript function to validate whether a given value is number or not.
- 5. Write a JavaScript function to validate whether a given value is object or not.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement