I really don't understand the function - please, please help. And I don't get 25 in Price


It passes. I know it's wrong, But I really, really don't get it. Where have I gone wrong?
If the function is price and price is orangeCost*5 then why do I pass the tutorial and not see 25.00?

var price = 5
var orangeCost = function (price)
    var orangeCost = price * 5;


Try to console.log the orangeCost, otherwise it won't be printed.

var orangeCost = function (priceeach)
var orangeCost = priceeach*5;


i don't think not console.logging the orangeCost is the reason you don't see 25..

I am sorry my answer is wrong~~~


No worries. Thanks for your response! Maybe someone else will reply and we will both know what's wrong!


what really the problem


You are using a variable that is the same as the function name. In truth we do not need to create a variable in this simple function. Simply log out the computed value:

console.log(price * 5);

Without seeing the instructions, it's difficult to say if this what is asked for. Does it say to log the value in the function? or to return the value? Either way, it is as simple as above.

return price * 5;


@velmak Could you share the instruction?


Thanks for your help!
These are the instructions:
You want to declare a function that calculates the cost of buying 5 oranges
.You then want to calculate the cost of the 5 all together.
Write a function that does this called orangeCost()
It should take a parameter that is the cost of an orange, and multiply it by 5.
It should log the result of the multiplication to the console.
Call the function where oranges each cost 5 dollars.


So where's the problem?

When we stick with the instructions there is no price variable and we don't pass that variable to the function. Part of the problem is not sticking to instructions.


That's the call that the lesson checker is going to try. We can just as conveniently enter any price amount using this call expression. No need of a variable in this exercise. Everything else is covered above.


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