|
|
|||||||
|
Hi, I am a complete beginner ,trying to learn some Javascript. I was asking myself if there is a command , like the Goto command in Basic. I remember: 10 bla bla 20 bla bla 30 if (Something) goto 10 Or if this is more helpful: var number ; number = prompt("Please enter a number"," "); number = parseInt(number) if (isNaN(number)) { document.write("This is not a number<br />"); document.write(" Please try again!"); } else { var result ; result = 2*number ; document.write("The number times two is = "+result); } Just after the "Please try again",..., I'd like to make it return to the first line, therefore asking the user to add another input,... Could anybody point me in the right direction of a command which would do this? Many Thanks |
||||||||
|
|
|||||||
|
'goto' is considered 'evil' in every progamming language other than Basic (very long story as to why...).. in this case you actually want to do a 'while' loop. It returns to the top of the {} as long as the condition remains true. var number;
Paul Lomax Internet Technology Manager IPC Country and Leisure Media - www.ipcmedia.com Pick Me Up magazine - Real life as you've never seen it before! |