Javascript script help Syntaxerror: Missing ; before statement

Asked

Viewed 148 times

1

Good evening, I’m having trouble making if/Else if/Else conditions in javascript, in the js course of Codecademy works, but when I try to make some algorithms in the sublime using the conditional, gives the error described in the title.

<script>
    var note1, note2, media;

        note1 = parseFloat(prompt("Informe a primeira nota"));
        note2 = parseFloat(prompt("Informe a segunda nota"));

        media = (note1 + note2) / 2;

        if (media >= 5.0) or (media <= 6.0){
            console.log("Você é um mau aluno");
        }
        else if (media >= 6.1) or (media <= 7.0) {
            console.log("Você é um aluno mediano");
        }
        else {
            console.log("Você é um excelente aluno");
        }
</script>

1 answer

1


Any condition in the if must be in parentheses.

  • It is allowed to use multiple parentheses within the if, as long as it has one encompassing everything
  • Your comparisons are wrong, some languages accept or and and but java script uses && for and and || for or
  • if ((media >= 5.0) || (media <= 6.0)){
    //...
    else if ((media >= 6.1) || (media <= 7.0)){
    

    Browser other questions tagged

    You are not signed in. Login or sign up in order to post.