7. Return Keyword


#1


https://www.codecademy.com/courses/javascript-beginner-en-6LzGd/1/2?curriculum_id=506324b3a7dffd00020bf661


Hi this is my code.

// Parameter is a number, and we do math with that parameter
var timesTwo = function(number) {
    return number * 2;
};

// Call timesTwo here!
var newNumber = timesTwo(8);
console.log(newNumber);

It keeps saying "Oops, try again. Your code doesn't look quite right. Did you set var newNumber = timesTwo(n), where n is whatever number you want?"

Don't know what i'm doing wrong. HELP! Thanks. :slight_smile:


#2

Your code looks good. I would reset and do it again. That's not a real solution but it's that kind of problem.


#3

Thanks, all I had to do was reload the page. :slight_smile:


#4

I'm stuck on Lesson 8 now. Help if possible!:grinning:


#5

If you're still stuck, please put your code up and what error code you are getting.


#6

Thanks for the concern @astrophe717.
My code is:
// Define quarter here.
var quarter = function quarter(number)
{
((number) / 4);
}

if (quarter(27) % 3 === 0 ) {
console.log("The statement is true");
} else {
console.log("The statement is false");
}

Thank you. Hope you can help. :innocent:

Arianator10


#7

27 % 3 == 0 so that is fine. Actually from the start of the if statement all of your code is fine.

You need to make changes to the function:

  1. Decide which 'quarter' is correct and remove the other (look at the function you wrote in lesson 7 for help).

  2. Inside your function is the code to be executed. You need to tell JavaScript what you want it to do with the executed code. In this case you just want to return the result. So write return number / 4;.

I hope this helps.


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.