Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

JS - Logical operators OR || AND && NOT!

0 votes
17 views
added Jul 6 in Javascript by LC Marshal First Warrant Officer (11,130 points)
edited 5 days ago by LC Marshal
// || OR logical operator
let result = prompt('what should be the Messi jersey number', '');
if ( result == (11 || 10)) {  
  alert( 'Most likely' );
} else if ( result == (null || '')) {
  alert('Please answering');
} else {
  alert ('couldnt be');
}

1 Response

0 votes
responded Jul 6 by LC Marshal First Warrant Officer (11,130 points)
edited 5 days ago by LC Marshal
console.log( null || 2 || undefined ); //The answer is 2, that’s the first truthy value.
console.log( 1 && null && 2 ); //The answer: null, because it’s the first falsy value from the list.
lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...