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


#1

Hello.
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)
{
console.log("orangeCost");
};
orangeCost("5 dollars")

Introduction to Functions in JS
6. Don't Repeat Yourself (D.R.Y)
https://www.codecademy.com/courses/javascript-beginner-en-6LzGd/1/1?curriculum_id=506324b3a7dffd00020bf661#


#2

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


#3

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).


#4

thanks jibblyj! I was also stuck here :slight_smile:


#5