Lesson. 6 Dont repeat yourself help


var orangeCost = function(cost) {
console.log("oranges" + " " + "cost" + " " + cost);
this is the code I have I don't know how to multiply the number by five so can someone please help


Hey @iwannamakevideogames! The problem with that is when you call it never put it as a string.

Just do orangeCost(5);

Hope that helped!


I figured out that the problem was I wasn't doing
console.log(cost * 5);
I found this out by surfing through the forums for people having problems with this too



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



Why did you put the val? What does that mean?


You're literally the only person out of all the forums on this particular exercise that typed it correctly..


Why this doesn't work?!

var orangeCost = function(price);


there should not be a semicolon at the end of the first line. The structure should look like this:

var functionName = function(parameter) {
  //do some stuff ;
  //do some other stuff if you need to ;

Take a look at where all of the brackets and semicolons are and compare it to your code. Hope that helps!


hope it will help
var orangeCost = function(price) {



Thank you very much!


hola tengo esto pero no me funciona por fa me ayudan

var costoNaranjas = function (precio) {

console.log (precio*5);

costoNaranjas (5);


var orangeCost = function(price){
var value = price * 5


this worked for me and printed out the text i'm not sure that would be right as it dosen't write the answer to the task


ok it seemed to work for me


My issue is that my function works but it prints to console twice.

var orangeCost = function(price) {
var x = price * 5;
console.log("Oranges are " + x + " dollars today");



Try using "return x " at the end


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