0% found this document useful (0 votes)
8 views2 pages

Functions Exercices

Uploaded by

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

Functions Exercices

Uploaded by

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

TP 3:

Exercice 1.
Write a JavaScript function that reverses a number.
Example x = 32243;
Expected Output : 34223

Exercice2.
Write a JavaScript function that checks whether a passed string is a palindrome or not?
A palindrome is word, phrase, or sequence that reads the same backward as forward, e.g.,
madam, mom, deep….

Exercice 3.
Write a JavaScript function that generates all combinations of a string.
Example string : 'dog'
Expected Output : d,do,dog,o,og,g

Exercice 4.
Write a JavaScript function that returns a string that has letters in alphabetical order.
Example string : 'webmaster'
Expected Output : 'abeemrstw'
Assume punctuation and numbers symbols are not included in the passed string.

Exercice 5.
Write a JavaScript function that accepts a string as a parameter and converts the first letter
of each word into upper case.
Example string : 'the quick brown fox'
Expected Output : 'The Quick Brown Fox '

Exercice 6.
Write a JavaScript function that accepts a string as a parameter and finds the longest word
within the string.
Example string : 'Web Development Tutorial'
Expected Output : 'Development'

Exercice 7.
Write a JavaScript function that accepts a string as a parameter and counts the number of
vowels within the string.
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

Exercice 8.
Write a JavaScript function that accepts an argument and returns the type.
Note : There are six possible values that typeof returns: object, boolean, function, number,
string, and undefined.

You might also like