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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Mark Bradshaw](https://secure.gravatar.com/avatar/d4d4a89cb51e9faa9ded5e296b372344?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Mark Bradshaw
Courses Plus Student 7,658 PointsStuck on a jquery quiz question.
Here's the task: On line 11 in app.js, implement the isUsernamePresent function. Return true if the username length is greater than 0.
Here's my code: My answer:
function isUsernamePresent() {
if(isUsernamePresent().val().length > 0;)
}
Return true;
4 Answers
![Jason Anello](https://secure.gravatar.com/avatar/d1304e75238ff7f216f55adc03e08ea1?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Jason Anello
Courses Plus Student 94,610 PointsHi Mark,
You have a few errors.
You used a capital 'R' for `return. You have also placed your return statement outside your function. You will need to get it back inside the closing curly brace.
You also have a misplaced semicolon at the end of your if
condition and you don't want to call the function inside of itself.
You should use the $username variable which is storing the username input as pointed out by Michael.
function isUsernamePresent() {
if ($username.val().length > 0) {
return true;
}
}
Also, whenever you have this pattern of, "if something is true, return true", you can just return that something directly. Making your code a little simpler.
function isUsernamePresent() {
return $username.val().length > 0;
}
![Jonathan Grieve](https://uploads.teamtreehouse.com/production/profile-photos/601842/micro_twitterCover.png)
Jonathan Grieve
Treehouse Moderator 91,253 PointsYou have a capital R on your return keyword.
return is a specific keyword which isn't recognised if you capitalise it. :)
![Michael Escoto](https://uploads.teamtreehouse.com/production/profile-photos/125103/micro_beach.jpg)
Michael Escoto
30,028 PointsI think the problem is you're calling the function name in the if statement.
Instead you'll need just use:
if($username.val().length > 0)
![Vittorio Somaschini](https://uploads.teamtreehouse.com/production/profile-photos/740312/micro_Schermata_2014-03-27_alle_14.37.50.png)
Vittorio Somaschini
33,371 PointsYes Michael and Jonathan are both right Mark.
return needs to be all lowercase.
Also, the if condition should check the length of the value inside the $username variable (declared by the code at the beginning on line 5.
So $username.val().length is the right thing to do here
Mark Bradshaw
Courses Plus Student 7,658 PointsMark Bradshaw
Courses Plus Student 7,658 PointsThis clarification was exactly what I needed. Thanks.