LoginSignup
1
0

More than 5 years have passed since last update.

配列の要素の最大値 / 最小値を求める[Javascript]

Posted at

Mathオブジェクトとスプレッド演算子を使う

const arr = [10, 5, 100, 50, 1]
Math.max(...arr) // 100
Math.min(...arr) // 1

参考

Math.max

スプレッド構文

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