문제
일렬로 서 있는 학생의 키가 앞에서부터 순서대로 주어질 때,
맨 앞에 서 있는 선생님이 볼 수 있는 학생의 수를 출력
풀이 과정
const solutionA = (numberArray) => {
let studentHeight = numberArray[0];
let count = 1;
for (let i = 1; i < numberArray.length; i++) {
const currentStudentHeight = numberArray[i];
if (currentStudentHeight > studentHeight) {
studentHeight = currentStudentHeight;
count++;
}
}
return count;
};
const testA = solutionA([130, 135, 148, 140, 145, 150, 150, 153]);
console.log(testA);
틀린 부분이 있거나 보충해야 할 내용이 있다면 댓글이나 DM(sungstonemin)으로 알려주시면 감사하겠습니다😄