sicknesslife
07-28-2002, 12:38 AM
Hello,
I am doing an online javascript tutorial and i have the following code:
<script language="JavaScript">
<!-- hide me
var the_number = prompt("how many words (3-5 is good)?", "4");
var the_string = "";
var a_word;
for (loop = 0; loop < the_number; loop++)
{
line_number = loop + 1;
a_word = prompt("what's word " + line_number + "?","");
the_string = "word " + line_number + ": " + a_word + "<br>" + the_string;
}
var new_window = window.open("reverse.html","reverse","height=400,width=400");
new_window.document.writeln("<h1>In reverse</h1>");
new_window.document.writeln(the_string);
// show me -->
</script>
I can't figure out why this code is displaying the words i put in in the reverse order that i put them in, can someone please help....
I am doing an online javascript tutorial and i have the following code:
<script language="JavaScript">
<!-- hide me
var the_number = prompt("how many words (3-5 is good)?", "4");
var the_string = "";
var a_word;
for (loop = 0; loop < the_number; loop++)
{
line_number = loop + 1;
a_word = prompt("what's word " + line_number + "?","");
the_string = "word " + line_number + ": " + a_word + "<br>" + the_string;
}
var new_window = window.open("reverse.html","reverse","height=400,width=400");
new_window.document.writeln("<h1>In reverse</h1>");
new_window.document.writeln(the_string);
// show me -->
</script>
I can't figure out why this code is displaying the words i put in in the reverse order that i put them in, can someone please help....