0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

javascript 繰り返しの文 

Last updated at Posted at 2020-07-09

#はじめに
自分用のjavascriptの学習メモです。

for文の基本形

##for ofの基本形

const scores = [10,20,30]

for ( score of scores){
  console.log(score);
}

##for文の基本形

for(初期値; 繰り返す条件; 増減){}

例文


for (let i = 0; i < 10; i++ ){
  console.log(i);
}

上記は1から9が返る

#switchの場合


const date = 2;

switch(date){
  case 1:
    console.log('1です');
    break;
  case 2:
    console.log('2です');
    break;
  case 3:
    console.log('3です');
    break;
  default:
    console.log('該当しません');
    break;
}


======================
//簡単に書ける⬇️

if (date === 1){
  console.log('1です');
}
if (date === 2){
  console.log('2です');
}
if (date === 3){
  console.log('3です');
}
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?