0
0

More than 3 years have passed since last update.

JavaScript勉強の記録その1: If文

Last updated at Posted at 2020-01-04

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!');
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0