Skip to content

done 1,3,4,5,6#11

Open
jodich wants to merge 1 commit intowdi-sg:masterfrom
jodich:master
Open

done 1,3,4,5,6#11
jodich wants to merge 1 commit intowdi-sg:masterfrom
jodich:master

Conversation

@jodich
Copy link
Copy Markdown

@jodich jodich commented May 31, 2018

No description provided.

Comment thread script.js
// var testArray = [1, 2, 4, 8, 16, 32, 64, 128];
// var randomArray = [];

// // !!! ask, why the numbers come out so weirdly in the console
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.

If I'm seeing the same output as you are, you're seeing something like [ [1], [4], [128], ... ] right? That's because each element in that output array is an array itself, consisting of a single element. That means that your last line, randomArray.push(randomArrayValue), is actually pushing arrays into the randomArray...

Comment thread script.js
// console.log(inputName + "\'s number is " + inputNum);
// break;
// }
// }
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.

The instructions inside the if{} block are going to be run multiple times, because the condition eachName[i] !== inputName is going to return true most of the time. Testing for conditions inside a loop is something that has to be handled with care.

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