# Stuck on 6 help!

#1

what to do in this how to plz help i just dont understand what the word function means help

#3

The D.R.Y. principle is really important in programming. No repeating!

Any time you find yourself typing the same thing, but modifying only one small part, you can probably use a function.

The 'small part' that you find yourself modifying will be the parameter. And the part that you keep repeating will be the code in the reusable block - the code inside { }.

Instructions
You are a creature of habit. Every week you buy 5 oranges. But orange prices keep changing!

You want to declare a function that calculates the cost of buying 5 oranges.
You then want to calculate the cost of the 5 all together.
Write a function that does this called orangeCost().
It should take a parameter that is the cost of an orange, and multiply it by 5.
It should log the result of the multiplication to the console.
Call the function where oranges each cost 5 dollars.

#4

this is said on the left

#5

Write a function that does this `called orangeCost().`

`var orangeCost = function(price)`

It should take `a parameter` that is `the cost` of an `orange`, and multiply it by `5.`

``````var orangeCost = function(price) {
var val = price * 5;
console.log(val);
};``````

the parameter is `"price"` and we should multiply it by 5 so I saved it in the variable called `val` and then print it

last step: Call the function where oranges each cost 5 dollars.
outside that orangeCost function you should call it like that

``orangeCost(5);``

so all your code should be like that

``````var orangeCost = function(price) {
var val = price * 5;
console.log(val);
};

orangeCost(5);``````

#6

thanks that really helped i am on 7 now cya

#7

Or

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

orangeCost(5)