While loop

0 Mike Higgins · June 15, 2014
I'm needing to create a program that prompts the user for a number.  
Then I need to use a While Loop to count up to the number,,,
So if the user enters 7 my program will output the numbers: 7,8,9,10
If the user enters 3 it will output the numbers: 3,4,5,6,7,8,9,10

Post a Reply

Replies

Oldest  Newest  Rating
0 Mike Higgins · June 15, 2014
On the while loop I need it to count up to the number entered.  For example, if I enter 5 it will display:

1

2

3

4

5
0 Mathias Frits Rørvik · June 15, 2014
Like Pere said, you have to use the name variable, or assign the variable i to name.
0 Pere Garau Burguera · June 15, 2014
You have to use the name variable
0 Mike Higgins · June 15, 2014

i=i+1

0 Mike Higgins · June 15, 2014
I have tried as follows:

var name = prompt("Input a number");
var i;
i = 1;
while(i<=10)
{
document.writeln(i + "<br/>");
}



MY homework has instructed me that If I need help then post my issue w/In any forum help then link the help forum/Question and answer to the Assignments Discussion Board.


  • 1

Javascript

107,218 followers
About

A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.

Links
Moderators