Lesson 6:is my code correct?


Replace this line with your code. 
    var val=value*5;
    console.log("the cost is "+" "+val);

my answer is 25 but still it says " it looks like your orangeCost() function doesn't return 25 when the cost of an orange is 5."



I mean, technically it looks okay to me but seems a bit repetitive (this is the "D.R.Y." chapter, after all)... Can you see any line that may be unnecessary in your code?



yes got it , i removed the console.log ,thanks a lot ,@msfrisby


checker means what it kinda cecks the code for any errors?


Hi @jay8978,

No problem! But I went back and looked at the instructions for this exercise and think I gave you the wrong advice, sorry. Can you please check my edited answer?


Yes, that is what I mean by "checker". :slight_smile: But when I use it not necessarily for "errors" but "did you meet lesson objectives"


cool thanks! nice to meet you


Nice to meet you, too.

Were you able to figure out how to streamline your code while including console.log?



i didnt get you ? you mean did i understand how to include console.log?


Yep, in my original answer I suggested you might remove console.log because only one of the two lines are really needed to calculate the cost, but when I looked at the instructions they said they want you to print the cost (you need to use console.log). (This is when a link to the lesson can come in handy.)

So my question is: did you figure out how you can eliminate one line of your program while being sure to keep console.log?


when i am trying to include console.log , there's an error(i tried to reduce line) so can you please send me the code of what it is ?


@jay8978, why don't you share your code instead? :nerd:

Put it between two lines of three backticks (`) like this:

(your program)


var val=value*5;

@msfrisby please tell me where to add console.log


@jay8978 Just looking at your program without making any changes, if you had to choose one line to print which would it be?


it is the second line i guess @msfrisby


Yep, you're getting it! Anything else on that line seem like it could be whittled down?


console.log("the cost is "+" "+val);//wrong
console.log(val) //right
just console.log(val)
not anything else
return "the cost is "+" "+val; instead of console.log(val)



Hi! I just faced the same issue and decided to browse the forums for answer.
I find your response very helpful, however,
I would really appreciate it if you can explain a bit further.
Why does console.log("the cost is "+" "+val); print the response twice, and why is it wrong to use
console.log("the cost is "+" "+val);



@antonxx see this post re printing twice (generally).

iirc this exercise wants you to call your function and the function should print your sentence. If you print it below then you may be doing the work twice but I'd have to see the full program to be sure.

Whats wrong with my code?lesson 11

It makes sense. Thanks for the information.