Mathオブジェクトとスプレッド演算子を使う
const arr = [10, 5, 100, 50, 1]
Math.max(...arr) // 100
Math.min(...arr) // 1
参考
[スプレッド構文]
(https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Spread_syntax)
Go to list of users who liked
More than 5 years have passed since last update.
const arr = [10, 5, 100, 50, 1]
Math.max(...arr) // 100
Math.min(...arr) // 1
[スプレッド構文]
(https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Spread_syntax)
Register as a new user and use Qiita more conveniently
Go to list of users who liked