Why does console.log print twice


#1


https://www.codecademy.com/courses/javascript-beginner-en-6LzGd/1/1?curriculum_id=506324b3a7dffd00020bf661


CODE A

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

orangeCost(5);

CODE B

var orangeCost = function(cost){
console.log('The cost of 5 oranges at $5 apiece costs $' + cost * 5);
};

orangeCost(5);

There are no error messages but when I use Code A the console.log prints once:
25

When I use Code B the console.log prints the console.log twice
The cost of 5 oranges at $5 apiece costs $25
The cost of 5 oranges at $5 apiece costs $25


Replace this line with your code.


#2

var orangeCost = function(cost){
console.log('The cost of 5 oranges at $5 apiece costs $' + cost * 5);
};

orangeCost(5);

In this case system prints the last one.you can just ignore it or you can add following line at the end of your code.

console.log('The End')

so after this anything you see just ignore that.


#3

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