Write a function to find the smallest elements among three arguments. (You cannot use sorting methods.)
Solution
function solution(a, b, c){
/*
1. Declare a variable to store minimum element while comparing arguments
2. if a is smaller than b, store value of a in the variable
if not, store value of b in the variable instead
3. Either a or b is stored in the variable now
Compare it to the value of c and change the value of the variable if c is smaller than min
*/
let min;
if (a < b) min = a;
else min = b;
if (c < min) min = c;
return min;
}
Result