Stuck on this one, anyone know what i did wrong?


It's on "Don't Repeat Yourself (D.R.Y)" and i have no idea what i'm supposed to do.
I get the error "Oops, try again. It looks like you didn't define orangeCost."

var orangeCost = (5);
    console.log(orangeCost * 5);


Basic function syntax

// code

There should be a variable in the parameter, not a literal.

... = function (price) {
    console.log(price * 5);    // use whichever line is asked for; this
    return price * 5;          // or this

Note that there is no semicolon after the parameter.


then i get this error: SyntaxError: Unexpected token *


Please let us have another look at your revised code. Thanks.


var orangeCost = function(orangeCost * 5);

var orangeCost = function(

Everything up to here is correct. The parameter may not be an expression unless it is a default assignment, such as price=5. In this case we want to define a local variable called price and use it to store the argument. That will give us this for a function definition:

var orangeCost = function (price) {


That line will not print to the display what we expect. unless we are looking for,


What we want to do is multiply the value stored in price by 5 and log it.

console.log(price * 5);

Finally we call the function,


The 5 is the argument and will be stored inside the function in price. The output to the display will be,



I did it, thanks for the help!


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