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
Neil Berriman
3,230 PointsQuestion on a JQuery code challenge
HI Neil here, this is my answer for this challenge has anyone else got stuck on this.
Create a method called 'isValidEmail' that takes one argument that returns true when a string with an '@' symbol is passed, false if not.
function isValidEmail(email){
return email.indexOf("@") != -1;
}
Regards, Neil
2 Answers
Mohammad Forouzani
830 PointsThe problem with this is that it will throw an error if you give it anything other than a string.
For example:
isValidEmail(55);
will cause an error.
You could do a type check first... something like:
if (typeof email != 'string') {
return false;
}
Andrew Chalkley
Treehouse Guest TeacherHi Neil are you still having issues with this challenge?