(Solved) Burlbole grove(JAVA)

Hello, community, been stuck on this SUBJ level, googled, and tried youtube, nothing helped.
Will break it into two parts, function and execution.
First of all, there was no lesson on ‘NOT operator’, but from googling I’ve realized in real JAVA it’s" !="
when I’ve tried using != gives me mistakes, looked up in hints, and there just only “!” sign

so here’s my function logic:

// if there's no !taget return false 
//but if there's target beast burl, retuns false (don't touch him)    
//otherwise if something else returning true
function shouldAttack(target) {
    if (!target) {
        return false;
   
    if (taget.type == "burl");
        return false;
    
    } else {
        return true;
    }
}

tnx for your replies

There is a typo on Line 5 (target, not taget :wink:), as well as an incorrectly placed semicolon. Where is the identifier? :wink:

Other than that, it looks good :slight_smile:

tnx for your reply, I guess I’m too tired for today lol, already did like 20 lvl in forest, there was also mistakes with {}
so what’s the different between “!” and “!=” operators?

1 Like

!= is the Python version (not sure if it appears in others?)

1 Like

that it’s a bug, because in javascript we use !=

1 Like
// not equal:  !=
// usage: compares the operands on both sides of the "!="
//        and returns true if the operands are not equal to each other;
//        else, it returns false
if ( 1 != 2 ) {
    hero.say("1 does not equal 2");
}

// not:  !
// usage: if the following expression is true, the ! operator returns false;
//        if the following expression is false, the ! operator returns true.
if ( !( 1 != 2 ) ) {    // this is basically: if ( !(true) )
    hero.say("the hero won't say this");
}

Note that the != operator compares two values on both sides.
The ! operator only uses a true or false value to the right side.

More on the not operator
if ( !true ) { } // !true evaluates to false

if ( !false ) { } // !false evaluates to true
3 Likes