Step 7. Why using OR instead of a new if statement will not work?


#1

The instructions tell me to use nested if statements instead of using OR inside of the first if block.

The code according to the instructions would be like this:

   `if(charactersLeft < 0){
        $('.btn').addClass('disabled');
    }
    else if(charactersLeft === 140){
        $('.btn').addClass('disabled');
    }
    else{
        $('.btn').removeClass('disabled');
    }`

However, this should also work in order to save some piece of code:

    `if(charactersLeft < 0 || charactersLeft === 140){
        $('.btn').addClass('disabled');
    }else{
        $('.btn').removeClass('disabled');
    }`

I don't understand why the latter does not work.


#2

Hi Will,

I think that both will work fine, but the code checker is expecting you to have the else if statement rather than using an || thing, so it throws an error, regardless of whether it actually works or not.