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 trialRemi Vledder
14,144 Pointswrap it up in an anonymous function (video transcript 8:49)
By the end of the movie clip you mention at 8:49 "You may want to wrap this up in an anonymous function, and you call the password and the confirmed password together on two separate lines."
Can you provide a example?
1 Answer
Fidel Severino
3,514 PointsRemi,
I'm guessing he meant something like this:
// When event happens on password input
$password.focus(function() {
passwordEvent();
confirmPasswordEvent();
}).keyup(function() {
passwordEvent();
confirmPasswordEvent();
});
Although I'd really like to see someone with more experience, or better yet, the instructor himself, provide an example of what he meant. If it's like what I wrote above, to me that looks more confusing than the original line:
$password.focus(passwordEvent).keyup(passwordEvent).focus(confirmPasswordEvent).keyup(confirmPasswordEvent);
Which can be cleaned up by doing:
$password.on("focus keyup", function() {
passwordEvent();
confirmPasswordEvent();
});
Jason Anello
Courses Plus Student 94,610 PointsHi Fidel,
That last one seems like a good idea. I hadn't thought of that.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsTagging Andrew Chalkley