자연수 n을 뒤집어 각 자리 숫자를 원소로 가지는 배열 형태로 리턴해주세요. 예를들어 n이 12345이면 [5,4,3,2,1]을 리턴합니다.
n은 10,000,000,000이하인 자연수입니다.
function solution(n) { const arr = n .toString() // 12345 .split("") // ["1","2","3","4","5"] .reverse() // ["5","4","3","2","1"] .map(n => Number(n)); // [5,4,3,2,1] return arr;
class Student { constructor(name, age, enrolled, score) { this.name = name; this.age = age; this.enrolled = enrolled; this.score = score; } } const students = [ new Student('A', 29, true, 45), new Student('B', 28, false, 80), new Student('C', 30, true, 90), new Student('D', 40, false, 66), new Student('E', 18, true, 88), ]; const result3 = students.map(student => student.score); console.log(result3);