Don't Repeat Yourself (D.R.Y.) Calculating Oranges Question


I am having trouble with Don’t Repeat Yourself (D.R.Y) Calculating Oranges. I have done this so far:

var price = prompt (“Price of a orange”);

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

My code doesn’t seem to be working correctly. I was wondering if someone could help clarify or explain this to me? Thanks in advance!
Here is the link:


Hi @helenbella, let’s see what your code does right now:

We declare our variable, price that has a prompt: prompt("price of an orance"); assigned (=) to it. prompt will ask us to type something in.

Next, we have our function orangeCost, JS knows it’s a function because we assigned it to function(). In the body of the function (which is within the brackets), we use console.log() to print price multiplied by 5.

There is a problem, though. We can’t do math with a string and an int. :man_shrugging: You should reread the instructions, think about what they’re asking you to do, and try again. :slight_smile:


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