Help us understand the problem. What is going on with this article?

【JavaScript】 js 繰り返し文 for / while/ case

【ゴール】

JavaScriptで使える繰り返し文

【メリット】

■ javascript理解度向上
■ リーダブルコード実現

【開発環境】

■ Mac OS catalina
■ Ruby on Rails (5.2.4.2)
■ Virtual Box:6.1
■ Vagrant: 2.2.7

【コード】

1-100まで1つずつ足されていくという処理を例にします。

while

※()に条件
※{}に出力処理 & 加算処理

hoge.js
while(number <= 100){
 console.log(number);
 number ++ ;
}

for

※forは条件を()内に全て記述、シンプルで◎

hoge.js
for(number = 1; number <= 100; number ++){
 console.log(number);
}

switch

*()に条件記述
*caseのあとは「:」(コロン)ダブルコロンじゃない!!
*breakで終了
*defalutはif文のelseと同じ意味

hoge.js
switch(条件){
  case 条件後の値: 
  console.log(‘出力したい文字’); 
  break;
.
.
.
  // default
}

以上!!!
コードライン色付けしてみました!!!

【合わせて読みたい】

■ 【jQuery】初心者でもよく理解できたやつ
https://qiita.com/tanaka-yu3/items/a03734b248c3f2ee8461

■ 【メソッド集】 rails メソッド まとめ 基礎 随時追加
https://qiita.com/tanaka-yu3/items/89abad875187494bec53

■ 【JavaScript】javascriptの基本
https://qiita.com/smkhkc/items/5e3729cffab6591f34c6

tanaka-yu3
さくっと30秒で読める記事をたくさん 初学者向け
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした