0
how can i use if else statement to find the minimum of a and b and assign it to variable min?
var a = 2000; var b = 1000; var min; if (a < b) { // TODO: assign min } else { // TODO: assign min } console.log("The minimum of a and b is: " + min);
3 Respostas
+ 16
// Homework?
var a = 2000;
var b = 1000;
var min;
if (a < b) min = a;
else min = b;
console.log("The minimum of a and b is: " + min);
+ 4
// You can do it even shortener, using ternary operator ;)
var a = 2000;
var b = 1000;
var min;
min = (a < b) ? a : b;
console.log("The minimum of a and b is: " + min);
0
thanks brother