may88seiji
5/23/2017 - 5:17 AM

Given a set of numbers, return the additive inverse of each. Each positive becomes negatives, and the negatives become positives. https://w

Given a set of numbers, return the additive inverse of each. Each positive becomes negatives, and the negatives become positives.

https://www.codewars.com/kata/invert-values/solutions?show-solutions=1

  function sol(array) {
        return array.map(function(n) {return n === 0 ? 0: -n;});
    } 
    sol([1,2,3,4,5]) ;
function invert(array) {
   return array.map( x => x === 0 ? x : -x);
}
    invert([1,2,3,4,5]) ;