(1) X : array.findIndex
function solution(array) {
const maxNum = Math.max(...array);
const maxIdx = array.findIndex(maxNum);
return [maxNum, maxIdx];
}
(2) O : array.indexOf
function solution(array) {
let maxNum = Math.max(...array);
let maxIdx = array.indexOf(maxNum)
return [maxNum, maxIdx];
}
function solution(array) {
const max = Math.max(...array);
return [max, array.indexOf(max)];
}