I need help. please. 6. Don't Repeat Yourself (D.R.Y)


Please write the correct code to this 5 oranges, I'm really confused and can't pass this lesson.
What's the point of a "hint" if it doesn't help you.
all ive done is this:

var orangeCost = function(price * 5)
orangeCost("5 dollars")

Introduction to Functions in JS
6. Don't Repeat Yourself (D.R.Y)


ok so there are a couple of problems but they are easy so don't worry.
first off the function sould take the parameter cost.
then you console.log(cost * 5);
then outside of the function call the function with the cost of 5


You need one parameter (argument) for your orangeCost() function, and inside the function you must console.log() the result of that parameter multiplied by (*) 5;

var orangeCost = function(price) { // 1
    console.log(price * 5); // 2
}; // 3
orangeCost(5); // 4

Take a look at the comments.

Where I commented 1, this is where you are declaring the function, with the parameter price (this is the thing that can change).
Where I commented 2, this is where you're logging the price of the orange, multiplied by 5.
Where I commented 3, that's where you're closing the function.
Where I commented 4, that's calling the function with a parameter of 5 (one orange costs 5).


thanks jibblyj! I was also stuck here :slight_smile: