function solution(array, commands) {
const answer = [];
commands.forEach(command => {
// 구조분해 할당하여 가독성 up
const [startIdx, endIdx, idx] = command
const temp = array.slice(startIdx - 1, endIdx)
.sort((a, b) => a - b);
answer.push(temp[idx - 1]);
})
return answer;
}