Help in Introductions to Functions: Don't repeat yourself


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.

Here's what I did:

var orangeCost = function (price) {
console.log("Oranges now cost $" + "" + price);


The log shows Oranges now cost $25 and on the next line says Oranges now cost $5 like this:
Oranges now cost $25
Oranges now cost $5

And it's saying that my "orangeCost() function doesn't return 25 when the cost of an orange is 5."



Here is the answer of your question:

They want to multiply the cost of orange by 5 in the body of your function. And you are printing the cost of only 1 orange.
Remove this strings "Oranges now cost $" + "" and just print (price * 5) instead of price.

And invoke the function with 5 not 5*5


hello, just wondering. i got stuck on this problem also and was looking for answers but somehow your answer did not work, i ended up using this
var orangeCost = function (price) {
console.log("5" * price);


just wondering how this could be.


5 isnt a string put it without the quotes

so its just
console.log(5 * price); or
console.log(price * 5);
depending on which way round you prefer to write it