Exercise

Write these following in While Loop and For Loop :

  1. Write a JavaScript loop that will iterate from 0 to 10. For each iteration of the for loop, it will multiply the number by 9 and print the result.

  2. Write a JavaScript program to calculate the factorial of a number. For example, 5! = 5 x 4 x 3 x 2 x 1 = 120.

  3. Write a JavaScript program to get the first n Fibonacci numbers. Note : The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, . . . Each subsequent number is the sum of the previous two.

results matching ""

    No results matching ""