6/13 Please Help


#1

What am I doing wrong? Please describe the correct answer and what I did wrong as if I am a toddler. I started javascript two nights ago.

var orangeCost = function(price)
{;
console.log(price*5);
};
price = 5

"Oops, try again. It looks like you didn't call the orangeCost function. Make sure to call it and pass it a price!"


#2
var orangeCost = function(price)
{;
    console.log(price*5);
};

this is ok just this semicolon here:

var orangeCost = function(price)
{; <-- this one

is redundant. But what you should do now is to call the function which is done by functionName + (). In your case orangeCost() instead of price = 5. Now this would result in NaN being printed but at least your function would be running. What you need to do now to fix this is to pass an argument to the function meaning you need to add a value in the () after the function call e.g. orangeCost(5). What happens now is that this value is assigned to your parameter so when you console.log price*5, price will have a value of the argument. In our case it will be 5 so you see 25 being printed. And that would be pretty much it. I doubt that a toddler will understand this but maybe you evolved a bit already :smile: good luck and keep asking if things aren't clear.


#3

var orangeCost = function (price){
console.log (price*5)
};
orangeCost(5)


#4

you can see what i did on


#5

function orangeCost(price) {
console.log(5 * price);
}

orangeCost(5)

This is the answer, hope it helps and you understand it :).