Min of Three

Problem

Write a program that accepts natural numbers A, B, and C less than or equal to 100 and prints the smallest of the three numbers. (don’t use sort)

input

Three natural numbers less than or equal to 100 are entered in the first line.

6, 5, 11

output

Print the smallest number on the first line.

5

Solution

using if

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

	if (c < answer) answer = c;
	return answer;
}

using sort()

function solution(a, b, c) {
	let answer = [a, b, c];
	answer.sort((a, b) => a - b);
	return answer[0];
}

using Math.min()

function solution(a, b, c) {
	return Math.min(a, b, c);
}