× Introduction Setup Environment Building blocks Built-in functions Data Types Strings Operators Conditional statements Loop statements Functions Arrays Understaing Objects Date Object Number Object Math Object String Object Window Location Navigator History DOM Basics Forms
   Programs
Basic Control Loops Functions Arrays Examples Projects Quick Ref.
   Exercises
Variables Data Types Operators Decision Loops Reeborg's World



JavaScript Looping (Repeating Tasks) Programs

While loop challanges

1.Ask the user to enter their name and then display their name three times using while loop.

View     Try It

2.Ask the user to enter their name and a number and then display their name that number of times using while loop.

View     Try It

3.Print 10 natural numbers using while loop.

View     Try It

4.Ask for a number below 50 and then count down from 50 to that number, making sure you show the number they entered in the output.

View     Try It

5. Set the total to 0 to start with. While the total is 50 or less, ask the user to input a number. Add that number to the total and print the message "The total is… [total]". Stop the loop when the total is over 50.

View     Try It

6. Ask the user to enter a number and then enter another number. Add these two numbers together and then ask if they want to add another number. If they enter "y", ask them to enter another number and keep adding numbers until they do not answer "y". Once the loop has stopped, display the total.

View     Try It

7. Ask for the name of somebody the user wants to invite to a party. After this, display the message "[name] has now been invited" and add 1 to the count. Then ask if they want to invite somebody else. Keep repeating this until they no longer want to invite anyone else to the party and then display how many people they have coming to the party.

View     Try It

8.Ask the user to enter a number between 10 and 20. If they enter a value under 10, display the message "Too low" and ask them to try again. If they enter a value above 20, display the message "Too high" and ask them to try again. Keep repeating this until they enter a value that is between 10 and 20 and then display the message "Thank you".

View     Try It

9. Create a variable called compnum and set the value to a random number. Ask the user to enter a number. While their guess is not the same as the compnum value, tell them if their guess is too low or too high and ask them to have another guess. If they enter the same value as compnum, display the message "Well done, you took [count] attempts".

View     Try It

10.Write a program to enter a number and then calculate the sum of its digits.

View     Try It

11.Write a program to print the reverse of a number.

View     Try It

12.Develop a sum quiz using while-loop with play again choice and update score.

View     Try It

Do-While loop challanges

1.Ask the user to enter their name and then display their name three times using do- while loop.

View     Try It

2.Ask the user to enter their name and a number and then display their name that number of times using do-while loop.

View     Try It

3.Print 10 natural numbers using do-while loop.

View     Try It

4.Ask for a number below 50 and then count down from 50 to that number, making sure you show the number they entered in the output.

View     Try It

5.Write a do-while program to find sum of 10 natural numbers.

View     Try It

for loop challanges

1.Ask the user to enter their name and then display their name three times using for loop.

View     Try It

2.Ask the user to enter their name and a number and then display their name that number of times using for loop.

View     Try It

3.Print 10 natural numbers using for loop.

View     Try It

4.Ask for a number below 50 and then count down from 50 to that number, making sure you show the number they entered in the output.

View     Try It

5. Set the total to 0 to start with. While the total is 50 or less, ask the user to input a number. Add that number to the total and print the message "The total is… [total]". Stop the loop when the total is over 50.

View     Try It

6.Write a for loop program to find sum of 10 natural numbers.

View     Try It

7.Ask the user to enter a number between 1 and 12 and then display the times table for that number.

View     Try It

8.Write a program that displays a Celsius-to-Fahrenheit conversion table. Entries in the table should range from 10 to 100 degrees Celsius in increments of 5 degrees. Note: The formula f = (9/5*c) +32

View     Try It