Skip to content

Assignment Complete#6

Open
angkiki wants to merge 2 commits intowdi-sg:masterfrom
angkiki:master
Open

Assignment Complete#6
angkiki wants to merge 2 commits intowdi-sg:masterfrom
angkiki:master

Conversation

@angkiki
Copy link
Copy Markdown

@angkiki angkiki commented May 31, 2018

No description provided.

Comment thread script.js

if (userNumber == randomNumber) {
console.log("Your number matched the randomly generated one!");
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread script.js

if (!Phonebook[userPromptThreeName]) {
Phonebook[userPromptThreeName] = userPromptThreeNumber;
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()

Comment thread script.js Outdated
userFirstNumber = parseInt(userFirstNumber);
userSecondNumber = parseInt(userSecondNumber);

var newArray = MutateMeNot;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants