Why is it doing this?


#1

When I run my submit and save I get two outputs. I added a string to my code to give it some context and when I do this is outputs twice. When I remove the string and just have console.log(val); it works just fine, one output.

So my question is why does it run the output twice? I have no idea.


Replace this line with your code.


#2

Hey there, I have the same problem. Also the answer is 25 as it should be, but it's not correct.

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

This is my code.


#3

It only printed once when I tried, so I think it's just the way the lesson is structured.


#4

Look at orangeCost("5"). The input is a string, not a number. So when it goes to the line price * 5, how do strings multiply by 5?


#5

Envy, You are running the program from the command prompt in windows? I did not know you could do this.


#6

Yes thank you. I also had this problem in another exercise and now I understand the difference between string and a number.


#7

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