# Don't Repeat Yourself (D.R.Y)

#1

what is missing
var orangeCost = function(price) {
var val = price * 5
console.log(" the cost is " + " " +val);
}
orangeCost(5);

the result :
the cost is 25
the cost is 25

#2

Hi you should just print 25 so remove the string

``" the cost is " + " "``

inside the console.log()

#4

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

This worked but i dont understand how....could you explain????

#5

yes pls someone explain

#6

hey wizmarco can you please write the full code on the reply cause i'm stuck

heres what I got:

var orangeCost = function(price)
{
var val = price * 5
console.log(" the cost is " + " " + price);
};
orangeCost(5);

What am I doing wrong here??

#7

i have some difficult, result stamp 2 or 3 times, errors, prompt asked 2 or 3 or 4 times, i try different way, i found this working perfectly

var orangeCost = function (price) {
var fiveOranges = price * 5;
console.log(fiveOranges);
};
orangeCost(prompt("one orange price"));

#8

Hi this line

``console.log(" the cost is " + " " + price);``

the lesson want that you only print the number 25 so if you put a string before it will see it as an erro so remove

``" the cost is " + " " +``

and keep

``````console.log(val);
#So that will output
25``````

you should print val

#9

HI you should print 25 so when the prompt show up you should type 5

#10

What you have is good; but you can also shorten it this way:

// Defining the function and inserting its parameter - price
// Then just send it to the screen and multiply by 5

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

// Calling the function here and inserting the price, in this case 5 in the parameter

orangeCost(5)

// You should get 25.

#11

isnt that tantamount to doing the job for the computer as output?

#12

why is that are error ???
if so then what is the syntax

#13

Hi what error are you talking about? can you post your code ..

#14

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