DRY: output is NaN instead of 25


var orangeCost = funtion (price) {
console.log("price" * 5);

I am also having trouble with this section. can anyone debug my code?

Dont Repeat Yourself

console.log("price" * 5);

you don't use your parameter (variable name) price but instead try to multiply the word "price" with 5 which is probably impossible and results in NaN.


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

but the answer comes back "



And reply from emulator "Oops, try again.
Hmm, it looks like your orangeCost() function doesn't return 25 when the cost of an orange is 5.


plz help me with this section


Two things:
Revisit the main menu and select: '2. Introducing Functions' to read the analogy about bake instructions. You layout is incorrect and should look like this:

You have misspelt function but instead written funtion in line 1.
You have added quotations marks to the word price in line 2. I am a beginner myself, so this may be incorrect, but I believe this creates a new string where not required.

Hope this helps


How? What is your code and error message?


var orangeCost = function (price)
var val = price * 5


3 posts were split to a new topic: DRY: syntax error:unexpected token


var orangeCost = function (price) {
// need to declare variable
var value = price * 5;
console.log (value);