JavaScript JavaScript Basics Making Decisions in Your Code with Conditional Statements The Conditional Challenge Solution

Const vs Let in challenge

In this coding challenge, I originally used "let" instead of "const" for declaring the variables for the answers, but when I would run the code, it would not calculate answers correctly. Does anyone know why this is? I thought the only difference between using const, let, and var is the bugs you will run into when trying to redeclare a variable.

p.s. changing the declaration from let to const made the code execute perfectly

1 Answer

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 89,653 Points

Are you referring to the code challenge that is the final stage in this section? :-)

If so, try keeping the variables and constants,

But instead of the OR operator ||, change the expressions to use the AND operator. &&.

You'll need to make sure the expressions also cover each eventually for the money variable.