JS - #6 Don't repeat yourself - Help


#1

So... That's my code:
var orangeCost = function (price) {
var price = 5;
console.log(price * 5);
}
orangeCost(25);

as output I get: 25
25

and the error is:
"Oops, try again. Hmm, it looks like your orangeCost() function doesn't return 50 when the cost of an orange is 10."

Please help.


#2

You pass price in the function (when you have function(price) ). However, you overwrite this value when you assign price again (var price = 5;). You don't need to assign it again because it will always overwrite your passed value.


#3

Thanks a lot !
Solved my problem.


#4

Hi I believe my javascript is correct, but it is prompting me for the price two times

function orangeCost() {
var price = prompt("Orange price?");
var cost = (price * 5);
console.log("The cost of the oranges is" + " " + cost);
}
orangeCost();


#5

Try this:
var orangeCost = function (priceInput) {
console.log(priceInput * 5);
};
orangeCost(5)

THE COST SHOULD BE 25