Can someone help me


Why does it outputs two lines of "The cost is 25"

var orangeCost = function (price) {
    var total = price * 5;
    console.log("The cost is " + total);
orangeCost ("5");


Do you mind providing a link to the section you are on.


I don't if this the right answer, but I will do it like this.
First we make the function

function price() {

Then we set the price for a Orange

var orangePrice = 5;

Then we make the variable total

var total = orangePrice * 5;

Then we print the total price with console.log, I use a space after "The cost" otherwise the output will look like this: The cost25.

console.log("The cost " + total);

I'm not sure this will work, but I hope it does. It is a different way, that I use.
I think it will now just put out 1 line.


I'm on 'Introduction to Functions in JS: Don't Repeat Yourself (D.R.Y)'


I found a solution for this. Check your coding here console.log('The Cost is' + total); There is something wrong with this code that you might want to get rid of. Checking this code will solve your answer.


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