While we're at it



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.


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.


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