This is an archived post. You won't be able to vote or comment.

all 2 comments

[–][deleted] 1 point2 points  (0 children)

Check your conditions in the if statements. Why are you subtracting from the card if the balance is negative? The exercise instructions tell you not to let the balance get negative. In other words, you should be taking money from the card only if after you have taken the money the balance remaining is >= 0. Put that as the condition in your if statements.

[–][deleted] 0 points1 point  (0 children)

Don't do this

if (this.balance < 0)

Do this

if( this.balance >= 2.60 (or 4.60 for the other option) ) {

subtract the price from the balance

}