Ad
Code
Diff
  • function neg(number) {
      return typeof number === "number"?-number:NaN;
    }
    • function neg(number) {
    • return -(number);
    • return typeof number === "number"?-number:NaN;
    • }

Object.is(NaN,NaN) === true;

Code
Diff
  • f=a=>
      !Object.is(a.sort()[0],a[1])? 
        a[0] : 
        Object.is(a[0],a=a.pop()) ?
          'Error'  :
          a
    • f=a=>
    • a.sort()[0]!==a[1] || isNaN(a[0])!==isNaN(a[1])?
    • !Object.is(a.sort()[0],a[1])?
    • a[0] :
    • a[0]===(a=a.pop()) ?
    • Object.is(a[0],a=a.pop()) ?
    • 'Error' :
    • a

Sometimes we buy something we may receive some change, so, how much?

#Examples:
getChange(4,10) => 6
getChange(4,100) => 96;
getChange(4.5,100) => 95.5;
getChange(3.5,5) => 1.5;
getChange(3.8,5) => 1.2;

###1 note this:youMoney > allPrice.
###2 Subtraction is not necessarily correct.
###3 Maybe you can use Math.

function getChange(allPrice,youMoney){
  return Math.round(youMoney*1000 - allPrice*1000)/1000;
}