Skip to content

Latest commit

 

History

History
21 lines (17 loc) · 299 Bytes

File metadata and controls

21 lines (17 loc) · 299 Bytes

A solution using if:

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

A solution with a question mark operator '?':

function min(a, b) {
  return a < b ? a : b;
}

P.S. In the case of an equality a == b it does not matter what to return.