Name: Dead. 2008-10-20 1:58
I have to know WHY these functions give the answers they do. I'm at a loss when it comes to figuring out what order a program will run shit.
If anyone can give any insight, thanks.
(10%) What is printed in the "alert" box at the end of running this JavaScript code fragment?
var i; // loop index
var flag = true;
for (i=0; i<5; i++) {
flag = !flag ;
}
alert(flag);
Next one:
(10%) What is printed in the "alert" box at the end of running this JavaScript code fragment?
var x = 5;
var f = 5;
if (x < 10 ) { x = x + 1; }
else if (x == 5) { x = x - 2 ; }
else if (x > 0) { x = x * 3; }
else { x = -8 ; }
if (f < 10 ) { f = f + 1; }
if (f == 5) { f = f - 2 ; }
if (f > 0) { f = f * 3; }
else { f = -8 ; }
alert("x: " + x + ", f: " + f);
Two more to come.
If anyone can give any insight, thanks.
(10%) What is printed in the "alert" box at the end of running this JavaScript code fragment?
var i; // loop index
var flag = true;
for (i=0; i<5; i++) {
flag = !flag ;
}
alert(flag);
Next one:
(10%) What is printed in the "alert" box at the end of running this JavaScript code fragment?
var x = 5;
var f = 5;
if (x < 10 ) { x = x + 1; }
else if (x == 5) { x = x - 2 ; }
else if (x > 0) { x = x * 3; }
else { x = -8 ; }
if (f < 10 ) { f = f + 1; }
if (f == 5) { f = f - 2 ; }
if (f > 0) { f = f * 3; }
else { f = -8 ; }
alert("x: " + x + ", f: " + f);
Two more to come.