I'm stuck and I don't know why it's not working (javascript functions)


This isn't working and I don't know why...
I'm stuck at Javascript > Functions > 6. D.R.Y. Don't Repeat Yourself >> https://www.codecademy.com/en/courses/javascript-beginner-en-6LzGd/1/1?curriculum_id=506324b3a7dffd00020bf661

It's saying: "Oops, try again. It looks like you didn't define orangeCost."

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



You have defined the orangeCost function, but during the first execution you change value of orangeCost to 25 (5 * 5). So orangeCost is no longer a function and codecademy fails to test your submission.

Solution? Do not use the same name for many variables:

var orangeCost = function (price) {
    var totalPrice = price * 5;




Thank you, that makes sense. My brain is getting scrambled over here. :slight_smile: Thanks again.


You're very welcome :slight_smile:


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