我最近开始做 OdinProject,我不太明白为什么这段代码不起作用

我最近开始做 OdinProject,我不太明白为什么这段代码不起作用

前两个 if...else 语句有效,但当我到达 //else if(score = 20 || score <=39)// 语句时,代码就崩溃了,当分数更改为 >39 时,它仍然显示分数为 20,并且响应仍然保持分数为 20。我只是想知道为什么它在那里崩溃了。如果分数 <20 或 <0 或 >100,它就可以正常工作。

let response;
let score = 75;
let machineActive = false;

if (machineActive){
    if( score < 0 || score > 100 ){
        response = "This is not possible, an error has occurred.";}
       
       else if(score = 0 || score <=19){
        response = "That was a terrible score — total fail!"}
       
       else if(score = 20 || score <=39){
        response = "You know some things, but it\'s a pretty bad score. Needs improvement."}
       
       else if(score = 40 || score <=69){
        response = "You did a passable job, not bad!"}
       
       else if(score = 70 || score <=89){
        response = "That\'s a great score, you really know your stuff."}
       
       else if(score = 90 || score <=100){
        response = "What an amazing score! Did you cheat? Are you for real?"}
       } else{
        response ="The machine is not turned on"}

相关内容