HOME > > js・if文

js

js・if文

基本

const atai1 = 99;
if (atai1 >= 100) {
 console.log(atai1);
} else if (atai1 < 100){
 console.log('100より小さい');
}

真偽

if (true) {
  console.log('こんにちは');
}

ランダムに変化

const randN = Math.random() * 10;
if (randN >= 5) {
  console.log('randNは5以上')
} else if (randN < 5) {
  console.log('randNは5未満')
}
console.log(randN);

このページのTOPへ