Can someone help me


#1


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");


#2

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


#3

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.


#4

I'm on 'Introduction to Functions in JS: Don't Repeat Yourself (D.R.Y)'
https://www.codecademy.com/en/courses/javascript-beginner-en-6LzGd/1/1?curriculum_id=506324b3a7dffd00020bf661


#5

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.


#6

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