Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Please help me if you can!

Hello guys, I don't understand this peace f code

function canSubmit() { return isPasswordValid() && arePasswordsMatching() && isUsernamePresent(); }

Does it mean that function canSubmit() { return isPasswordValid() === arePasswordsMatching() === isUsernamePresent(); }

or what? I know that it means && (and) Sorry for my English \ I will be very pleasure if you can rewrite my mistakes Thx a lot

1 Answer

Steven Parker
Steven Parker
230,274 Points

This is simple logical combining.

It is not the same as testing for equality (===). The and operator (&&) returns true when the values on either side are both true.

So what the function canSubmit does is to call three other functions (isPasswordValid, arePasswordsMatching, and isUsernamePresent. Each of these functions will return true or false. If all of them return true, then canSubmt will also return true. If any of the three returns false, then canSubmit will return false.

Thank you for your prompt reply