Help - Search - Members - Calendar
Full Version: Basic j.script question.. test tomorrow!
Mobile Electronics Australia > Off Topic / Other Discussion > Open Discussion
Stevey Tee
prompt user to enter a number to be used as a loop perimeter(ie. number of loop cycles).

Confirm that the user enters a number and if so run it through a parseInt.

within a 'for' loop, initialise the loop counter as 0, ,loop for as long as the user defined value, and increment the counter by 1. Within the loop , doc.write the calue of the loop counter along with a line break.

I can do the prompt, confirm and parseInt...but i wasnt taught properly the 'for' loop, and examples in the book are crap. If someone can finish it off im sure ill work it out... I HAVE A TEST TOMORROW AHHH!

this is what iv done:

var loopp = prompt("How many loop cycles?","");
var loopp = isNaN(loopp);
if(loopp==true){
loopp = parseInt(loopp);
}

thanx guys!!!!!!
Trough Lolly
for i = 1 to loopmax do
print out 'loop current [i] here'

of course you'd need to give loopmax a number or.. somehow define wat the highest count of the loop will be.
Trough Lolly
if u wanna be super tricky u can do?:

while i != loopmax
i = i++
print out current i
End While

(you owe me)
Matt P
for(int i=0, i<max, i++){
print i
linebreak
}
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.
 Runescape