Brevity is the soul of programming
You may have noticed that when we give a variable the boolean value true, we check that variable directly—we don't bother with ===. For instance,
var bool = true;
while(bool){
//Do something
}
is the same thing as
var bool = true;
while(bool === true){
//Do something
}
but the first one is faster to type. Get in the habit of typing exactly as much as you need to, and no more!
If you happen to be using numbers, as we did earlier, you could even do:
var myNumber = 1;
while(myNumber) {
// Do something!
}
Instructions
We've written the less succinct version in the editor. Correct it to the more elegant version!
?
Stuck? Get a hint
Hint
Your condition should only be:
while(bool)
That's the hint. Here is what I have in the editor. It constantly freezes up my browser.
var bool = true;
while(bool === true){
console.log("Less is more!");
bool = false;
}
var bool = true;
while(bool){
console.log("Less is more!");
bool = false;
}
\
var bool = true;
while(bool = true){
console.log("Less is more!");
bool = false;
}
var bool = true;
while(bool){
console.log("Less is more!");
bool = false;
}
They expect you to take out all the equals signs at which point the said browser, even in Opera has frozen up. I'm very desperate to solve this problem. Any help would be appreciated. I went ahead and got every possible point but I'm still very very stuck. I don't get what I'm trying to do at all and have exhausted every combination of bool.
Thanks,
Scylla
No comments:
Post a Comment