mardi 10 juillet 2018

JavaScript if statement didn't work

I have a function as below

function test (x){
  if(x==='a' || x!=='b' ||'c')
  {
    console.log('result');
    console.log(x);
  }
  else {
    console.log('wrong') 
  } 
}

test('123');

And I expect the output will log "wrong", but it log //result 123 as the picture below. I'm not sure is because the if condition can't work like this?

enter image description here

Aucun commentaire:

Enregistrer un commentaire