What did I do wrong?


var orangeCost = function(orangeAmount){
console.log(orangeCost * orangeAmount)


orangeCost = 5


Hello Prince_panda
Look at your code:

1) You set to oranceCost variable the function.
2) You set, now, to orangeCost, an integer value. It overwrites the old function.

Since your variable is storing a function, you should call it:


Between parenthesis, not using equal operator.


You did many things wrong in fact.

Read the exercice : the parameter for the orangeCost function is not the amount of oranges (which is always 5, it's written) but their price.

Then inside the function, although your calculation (amount * cost) is correct, don't forget that orangeCost is the name of the function that will display the TOTAL cost of the oranges. So use this variable (which is a function) inside of itself has no meaning here. Replace the whole thing by the price of an orange (=the parameter) * 5 .

Finally, you don't call your function the proper way. Its true it looks like a variable but it's a function. Only setting a variable won't make any action. Don't forget: variables are characteristics, functions are actions.

The final result is

var orangeCost = function (price)

orangeCost(3) // Replace '3' by any price


Thanks guys your advice helped :smiley: