7. Return Keyword



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);

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:


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


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


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


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


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:



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.


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