View Single Post

Old 06-25-2007, 03:46 AM   #3 (permalink)
Fallen
Junior Member
 
Join Date: Jun 2007
Posts: 1
Rep Power: 0 Fallen is on a distinguished road
I have fixed the code above so that now it works.Here is the working code.Enter a number var userInput;var userNumber;var upperLimit = 20;userInput = window.prompt('Please enter a number in the range 1 to ' + upperLimit,'');while ((userNumber = upperLimit)){ userInput = window.prompt('Please re-enter - number should be in range 1 to + upperLimit', ''); userNumber = parseInt(userInput);}document.write('<BR>'+'Your chosen number was ' + userInput)I saw the following things wrong:1) I deleted this text "M 150 TMAO3 Question 1 (i)" as it causes an error.2) Enclosed the HTML tag, instead of "HTML>" it is now ""3) You use the variable yourNumber in "document.write('<BR>'+'Your chosen number was ' +yourNumber)" which is not declared.4) userNumber needed to be assigned after you assign userInput.5) In your while loop you are using a variable called "UserInput" which is not declared. JavaScript is case sensitive so I replaced it with "userInput"6) I added a text argument to the "" tag.7) In the line that says "UserInput = window.prompt('Please re-enter - numbershould be in range 1 to + upperLimit, '')" you need to have a single quote after "to" and before "+".
__________________
Fallen is offline   Reply With Quote