While we're at it


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-ASGIv/0/1?curriculum_id=506324b3a7dffd00020bf661


A little error in this exercise. Right now the code is as below:

var coinFace = Math.floor(Math.random() * 2);

while(coinFace === 0){
    console.log("Heads! Flipping again...");
    var coinFace = Math.floor(Math.random() * 2);
}
console.log("Tails! Done flipping.");

I think line 5 shouldn't have the var statement, because it converts the variable in a local one. It has no repercussion in the execution, but I think it's not what you want to do (convert the variable in a local one, I think it has to stay global).

Hope it'll help someone.
Best regards.


#2

That's all in the same scope, a little silly to declare it twice so yeah it shouldn't look that if for no other reason than that the reader will question what the writer meant by it.

If let had been used instead, then they would be two different variables, same name but different scopes.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.