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 trialMaxim Andreev
24,529 PointsTask 1/3 - form-validation-and-manipulation/checking-values
Why would the below syntax be wrong for Task 1/3 - form-validation-and-manipulation/checking-values
function isValidEmail(email){ if (email.val() == "@") return true; else return false; }
Thanks
1 Answer
Leonardo Hernandez
13,798 PointsThe challenge answer for this task is very DRY. The code that you have written in the if parentheses already returns a true or a false value so it is redundant to again say return true or false.
Also, your function would return false if I typed leonardo@home.com because that does not equal "@".
Instead, the indexOf method on your parameter will check to see if its argument is at all present in the value of your email parameter.