bingqing46 / exercise

坚持每日练习
0 stars 0 forks source link

minimum #4

Open bingqing46 opened 5 years ago

bingqing46 commented 5 years ago
function min(arg, arg1) {
  if(arg - arg1 > 0) {
   return arg1;
  }else{
   return arg;
  }
}

console.log(min(0, 10));
// → 0
console.log(min(0, -10));
// → -10
bingqing46 commented 5 years ago

官方答案

function min(a, b) {
  if (a < b)
    return a;
  else
    return b;
}

console.log(min(0, 10));
// → 0
console.log(min(0, -10));
// → -10