Don't Repeat Yourself


#1

This is the code that I thought would work, can someone explain why this isn't correct? I DO have a correct version aswel but I do not seem to find the problem with this:

var orangeCost = function(cost) {
console.log("The total cost is:"+ cost * 5); <-- this part is the problem
};
orangeCost (5);

Code that works for me:

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


#2

Hi both are rigth , but the lesson want that you just print the price of 5 orange so when you add the string "The total cost is:" its see it as an error.


#3

Thanks glad to know i did it right tho haha