Return keyword activity


#1

timesTwo(5);
var newNumber = function timesTwo(n) {
console.log (newNumber);
};


#2

timesTwo(5);
var newNumber = function timesTwo(n) {
console.log (newNumber);
};


#3

whats wrong with this!


#4

Hi can you post all your code?


#5

that was everything I put in


#6

it keeps saying I need to print the variable 'newNumber' but I am
Here are the instructions:
On line 7, after the equals sign, call the function timesTwo with any parameter you want
02. Line 8 prints out newNumber. Notice how the value we return from timesTwo() is automatically assigned into newNumber.


#7

when you begin you should have that code

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

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

just click on Reset Code


#8

The code: :slight_smile:

var timesTwo = function(number) {
    return number * 2;
};
var newNumber = timesTwo(3);
console.log(newNumber);

#9

I do have that bit but I don't know what to do next


#10

I have this bit, the code works but I don't know why it is doing this


#11

I've reset the code loads of times but It still doesn't work! :sweat:


#12

now doyou have this code ?

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

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

if you have it

now lets see the instruction

On line 7, after the equals sign, call the function timesTwo with any parameter you want this line

// Call timesTwo here!
var newNumber =

they only aske you to call the function timesTwo after the = with any number you want..
Do you know how to call a funtion?


#13

yes I do know how to but its still not working


#14

Can you post your new code?


#15

timesTwo(5);
var newNumber = function timesTwo(n) {
console.log (newNumber);
};


#16

I haven't changed it much


#17

Like I already said your code should look like that

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

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

then

you will do what they aske you to do...

Now look at your code

timesTwo(5);
var newNumber = function timesTwo(n) {
console.log (newNumber);
};

And look How your code should be

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

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

Do that click on Reset Code so that your code will be reset then do that part of the instruction
On line 7, after the equals sign, call the function timesTwo with any parameter you want this line

// Call timesTwo here!
var newNumber =

they only aske you to call the function timesTwo after the = with any number you want..


#18

it says to add the function as well after the 'var newNumber = ' I have all the rest though


#19

It aske you to add the call function of the function timesTwo and put it after the equal sign just like that

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

the number can be any number you like it's just that... the lesson aske you to do..


#20

oh ok ill try that :smile: