🧑🏻‍💻 통붕이 의 Study Note

세 수 중 최솟값

// ▣ 입력예제 1
// 6 5 11

// ▣ 출력예제 1
// 5

문제 요약 설명

내가 풀어본 코드

function solution(a, b, c){
  let min = a < b ? a : b

  return c < min ? c : min
}

console.log(solution(6, 5, 11))
function solution(...rest){ //...arguments
	return Math.min(...rest)
         Math.min(a, b, c, d)
}

console.log(solution(6, 5, 11))

정답 코드

function solution(a, b, c){
    let answer;
    if(a<b) answer=a;
    else answer=b;
    if(c<answer) answer=c; 
    return answer;
}

console.log(solution(2, 5, 1));

문제 풀이 시작

가장 작은 값 비교


Math.min( ) 사용하기