Help with orangeCost problem


#1

val orangeCost = function(price)
{

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

I've read other solutions in the forum and I still can't figure out what I'm doing wrong. The error message is "Unexpected identifier". Help, please?


#2

You have to put 'var' at the start, not 'val'. So,

var orangeCost = function(price) {

Then, you can make another variable called f.e. 'val'

var val = price * 5;

Now, it will calculate the price times 5 (amount of oranges you buy per week), but you still need to console.log() the variable 'val'. You should be able to do that one by yourself.


#3

Why do you need the second variable called val? Simply printing price * 5 seems to work.


#4

That's what I did, just kept the console.log(price * 5) and corrected the val to var and it worked.

Thanks for the help--appreciate it from both of you!