11.Review


#1

So I have my code and it works, but it outputs whatever number I have in the "while" condition at the end, in this case three. Why does it do that?

for (i = 1; i < 11; i++){
console.log(i);
}
var Master = true
while(Master){
console.log("Much you learn, yes, yes!");
Master = false;
}
var count = 1
do {
console.log("light saber swing");
count++
}while(count<=3);


#2

I found the answer in another post. I guess the program they are using to teach code will output the last thing no matter what it is and so if I put a console.log("") at the end of it it doesn't display anything except for what it suppose to display.


#3

Yes that is a feature of console to echo the last value. One exception is if there is no value e.g. undefined which happens to be the "value" of console.log that's the reason you don't see something else when using console.log.