Hey folks,
I’m just diving into Javascript on Code Academy and I have a real quick question about the code I pasted below. It worked and I passed the section but I’m wondering why I am seeing an output of 25, 25, 50. I expected to just see 25. Something funky happening here?
I’ll past the instructions here:
[LEFT][I]“You are a creature of habit. Every week you buy 5 oranges. But orange prices keep changing!
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.”
code:
var orangeCost= function(price) {
var val = price * 5;
console.log(val);
};
orangeCost(5);
Again the output I see is:
25
25
50
Not a huge problem but I’m trying to grab all the details as I go along.
Cheers for the help!