More Exercise

Practices makes perfect. Try to create these following in Javascript code. Good luck!

  1. Write a JavaScript program where the program takes a random integer between 1 to 10, the user is then prompted to input a guess number. If the user input matches with guess number, the program will display a message "Good Work" otherwise display a message "Not matched". Use this code to get random number between 1 to 10: Math.floor((Math.random() *10) +1);

  2. Write a JavaScript function that checks whether a passed string is palindrome or not.

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

  4. Write a JavaScript program to compute the exponent of a number. Note : The exponent of a number says how many times the base number is used as a factor. 8^2= 8 x 8 = 64. Here 8 is the base and 2 is the exponent.

  5. Write a JavaScript program that accept two integers and display the larger.

  6. Write a JavaScript program to construct the following pattern, using a nested for loop.

    *  
    * *  
    * * *  
    * * * *  
    * * * * *
    
  7. Write a JavaScript program to remove duplicate items from an array (ignore case sensitivity).

results matching ""

    No results matching ""