How to get small and big value from an array using for of loop javascript?
From the code, I able to update the small value. But I am not able update the big value.
const arr = '2 3 1 1 8'.split(" ").map(Number)
let small = arr[0]
let big = arr[0]
for (let i of arr) {
if (big < arr[i]) {
big = arr[i]
}
if (small > arr[i]) {
small = arr[i]
}
}
console.log(small, big)