Code works fine without a statement but codecademy suggests I use it anyways

Hello, I have a question regarding an exercise.
IXvKKU8UFy20210825
On the left is my code and on the right is codecademy’s code
What is the “sale = false” part for?
The code works fine without it and the problem never specified it.
Here is the link to the exercise
https://www.codecademy.com/courses/introduction-to-javascript/lessons/control-flow/exercises/if-else-statements

This comes from the previous exercise where you first create the variable, then create the If statement, then it asks to reassign the sale value to false. This shows your If is not printing anymore.

Now, in this exercise you now write the else statement part to print ‘Time to wait for a sale.’ If you remove the false assignment it will print the ‘Time to buy!’ string.

So the code will run both ways but you will reach different parts of your If Else statement.

1 Like

Oh okay, I missed that part completely. My bad. Thanks for answering.

1 Like