Don't repeat yourself - Stuck here


#1

I get an error given below when I run my code
Oops, try again.
Hmm, it looks like your orangeCost() function doesn't return 25 when the cost of an orange is 5.

The result is shown as below
The cost of 5 oranges is 25
The cost of 5 oranges is 25


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


#2

use return instead of console.log

var orangeCost = function(price) {
    cost = price*5;
    return cost;
};
console.log(orangeCost(5))

#3

Thank you, It worked
"Return" was never introduced in earlier topics


#4

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