Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML jQuery Basics (2014) Creating a Password Confirmation Form Improving the form validation

Toni Caktas
Toni Caktas
16,478 Points

dont quite get the assigment

What do I need to return?

1 Answer

Hi Toni!

In the programming the term return means a function after its execution should return some value. For example:

function iAmFunctionAndIreturnValue () {
    return "I am the returning value!";
}

On the other hand a function can do not return a value. For example:

function iAmFunctionButIdonNotReturnAnything () {
    alert("I just show you this message, but don't return any value.");
}

By the way, function also can accept values:

function iAmFunctionAndIacceptValue (incomingValue) {
    alert("Hi, I've accepted this value: " + incomingValue);
}

In the code challenge you need to return boolean value "true".

The answers for challenge:

Code challenge, step 1 of 2, lines 10 to 14:

function isUsernamePresent() {
  // If length of an entered username is greater than 0 (it's not empty), we return "true"
  if ($username.val().length > 0) {
    return true;
  }
}

Code challenge, step 2 of 2, lines 24-26:

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