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.

JavaScript5,for文,配列,初心者向け

Last updated at Posted at 2020-12-14

5,配列とfor文をくみあわせる。

const weather = ["晴れ", "曇り", "雨", "雷"]
for (let i = 0; i < weather.length; i++) {
  let li = document.createElement("li");
  li.textContent = i;
  document.getElementById("number").appendChild(li);
  console.log(i);
}

旧 for (let i = 0; i < 10; i++) {
新 for (let i = 0; i < weather.length; i++) {

○○.length
が ["晴れ", "曇り", "雨", “雷”]の中の数だけ勝手にやってくれる

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?