Conversation
|
|
||
| if (userNumber == randomNumber) { | ||
| console.log("Your number matched the randomly generated one!"); | ||
| }; |
There was a problem hiding this comment.
Here, randomNumber actually goes from 0 to 9 because of the Math.floor function, e.g. if Math.random() gives 0.001, then Math.floor(0.001 * 10) gives 0. At the same time, Math.random() has a practically 0 chance of returning 1, which is needed in order for Math.floor to return 10 here.
|
|
||
| if (!Phonebook[userPromptThreeName]) { | ||
| Phonebook[userPromptThreeName] = userPromptThreeNumber; | ||
| }; |
There was a problem hiding this comment.
Just something to keep in mind, although we will likely not be going into sufficient depth to see the impact of this, checking for object properties like this is not generally safe. For example, try typing proto into the prompt :) Look into Object methods on MDN, specifically Object.hasOwnProperty()
| userFirstNumber = parseInt(userFirstNumber); | ||
| userSecondNumber = parseInt(userSecondNumber); | ||
|
|
||
| var newArray = MutateMeNot; |
There was a problem hiding this comment.
A small comment like this will not be sufficient, but this is the point of this extra exercise. newArray here stores only a reference to MutateMeNot. After what you've done below, try to console.log the value of MutateMeNot and you will see that it has also changed because everything you've done to newArray is also being done to MutateMeNot since newArray refers to MutateMeNot.
…remove array reference
No description provided.