Javascriptでif文
一番シンプルな形としてはif(条件式){Trueだった時の処理}と書くことができる。
index.js
const score = 90;
if (score >= 80) {
console.log('Great!');
}
if(条件式){Trueだった時の処理}else{Trueじゃなかった時の処理}という書き方もできる。
index.js
const score = 60;
if (score >= 80) {
console.log('Great!');
} else {
console.log('OK...');
}
条件式の中に&&や||を入れることで、ANDやORを表現することができる。
index.js
const score = 60;
const name = 'okuno'
if (score >= 50 && name === 'okuno') {
console.log('Good Job!');
}