DRY: output is NaN instead of 25


#1

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

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


Dont Repeat Yourself
#2

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.


#3

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

but the answer comes back "

NaN

"

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


#4

plz help me with this section


#5

Two things:
1.
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:

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


#6

How? What is your code and error message?


#7

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

#8

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


#11

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