LoginSignup
0
1

More than 1 year has passed since last update.

【JavaScript】複数の数値が定義されている配列dataから「各数値」と「40未満の数値がいくつあるか」を表示する

Posted at
<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <title>40点未満の人を割り出す</title>
    <script>
        var count=0; 
        var data = [59, 39, 100, 2, 15, 40, 84, 97, 39, 41, 39.9, 40.1];
        for(var i = 0;i<data.length;i++) {
            document.write(data[i]+'<br>'); // 配列データの表示
            if(data[i]<40){
              count++;
            }
        }
        document.write('<h1>40点未満の人は' + count + '人です</h1>'); // 40未満の数値の個数表示
    </script>
</head>
<body>
</body>
</html>

image.png

0
1
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
1