Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Aug 31, 2019. It is now read-only.

Conversation

@StevieIsmagic
Copy link

Hey, haven't been able to finish this project just yet. Could you show us best practice solutions that we could compare / learn from?

Thanks in advance!

// Return `undefined` if no elements pass the truth test.

for (let i = 0; i < elements.length; i++) if (cb(elements[i]) === true) return elements[i];
return 'undefined';
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually return undefined and not the string 'undefined'

if (Array.isArray(elements[i])) {
arr = arr.concat(flatten(elements[i]));
} else arr.push(elements[i]);
} return arr;
Copy link
Contributor

Choose a reason for hiding this comment

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

Put the return on the next line

}

comparePasswords(myPassword) {
if (this.password === myPassword) return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just do return this.password === myPassword; . It's automatically converted into a bool

// use `this` to access the object's `password` property.
// do not modify this function's parameters
// note that we use the `function` keyword and not `=>`
if (passwordToCompare == this.password) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing: return passwordToCompare === this.password;. Make sure to use === over ==

// return `true` if they match, otherwise return `false`

checkPassword(string) {
if (string === this.password) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as below

@SunJieMing SunJieMing closed this Sep 1, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.