Skip to content

Lisa Canini 18/18#147

Open
LisaCee wants to merge 7 commits intobloominstituteoftechnology:masterfrom
LisaCee:master
Open

Lisa Canini 18/18#147
LisaCee wants to merge 7 commits intobloominstituteoftechnology:masterfrom
LisaCee:master

Conversation

@LisaCee
Copy link
Copy Markdown

@LisaCee LisaCee commented Feb 1, 2018

No description provided.

@wlharvey4
Copy link
Copy Markdown

Lisa,
Your coding is marvelous. Great work.

One suggestion I have is to try to avoid traditional for-loops whenever possible. Those are not considered best practice for JavaScript unless there is no other way to accomplish the task.

In your 'graph.js' file, you used a traditional for-loop three times. I was able to convert each of those into a functional form successfully (maintaining all tests passing). The first and third were pretty straightforward. The second, contains, was a little tricky, and will not work with forEach.

See if you can refactor graphs.js to eliminate the traditional for-loops and use functional methods instead. If you any questions, please reach I'd anytime.

Wesley

@wlharvey4
Copy link
Copy Markdown

Lisa,
Yes, nice job with the refactor. The contains function can be written using Array.find, as that will exit with a value as soon as a boolean true is returned; otherwise it returns undefined. Most of the functional loops make you run through each of the elements, but find is different.

  contains(value) {
      if (this.vertices.find(vertice => vertice.value === value)) return true;
      return false;
    }

Wesley

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