function(x, left, right) {
  if (x < left) {
    return left - x;
  } else if (x > right) {
    return x - right;
  } else {
    return 0;
  }
}
function(x, left, right) {
  if (x < left) {
    return left - x;
  } else if (x > right) {
    return x - right;
  } else {
    return 0;
  }
}
function ( x , left , right ) { if ( x < left ) { return left - x ; } else if ( x > right ) { return x - right ; } else { return 0 ; } }
Determine the distance from x to [left, right].
Determine the distance from x to [ left right ] .