Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

JavaScript : 3 little problem about syntax or something

I am new about codind. I am working about a Tic Tac Toe project. But a problem how İ doesn’t expect was spawn.

const verifyVictory = () => {
    if(
        (state.c1 = state.c2 && state.c2 == state.c3 && state.c1 > 0) ||
        (state.c4 = state.c5 && state.c5 == state.c6 && state.c4 > 0) ||
        (state.c7 = state.c8 && state.c8 == state.c9 && state.c7 > 0) ||

        (state.c1 = state.c4 && state.c4 == state.c7 && state.c1 > 0) ||
        (state.c2 = state.c5 && state.c5 == state.c8 && state.c2 > 0) ||
        (state.c3 = state.c6 && state.c6 == state.c9 && state.c3 > 0) ||

        (state.c1 = state.c5 && state.c5 == state.c9 && state.c1 > 0) ||
        (state.c3 = state.c5 && state.c5 == state.c7 && state.c3 > 0) 
    ){
        return true;
    } else if {
        state.c1 != 0 &&
        state.c2 != 0 &&
        state.c3 != 0 &&
        state.c4 != 0 &&
        state.c5 != 0 &&
        state.c6 != 0 &&
        state.c7 != 0 &&
        state.c8 != 0 &&
        state.c9 != 0
    } {
        return null;
    } else {
        return false;
    }
};

I don’t know how can I fix it. I don’t know how to search to find solution on my issue in google.

My VS code editor with problems underligned

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thank

I tried to search on google but nothing about what I can understand..

>Solution :

It looks like there is a syntax error in the code you provided. The issue is with the else if statement: it is missing the condition that it is testing. Here is the corrected code:

 ){
    return true;
} else if (   <---------- here is the problem
    state.c1 != 0 &&
    state.c2 != 0 &&
    state.c3 != 0 &&
    state.c4 != 0 &&
    state.c5 != 0 &&
    state.c6 != 0 &&
    state.c7 != 0 &&
    state.c8 != 0 &&
    state.c9 != 0
) {
    return null;
} else {
    return false;
 }
};
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading