<<<<<<< HEAD Code Wars - Brett Crafton

Invert values

Question

Given a set of numbers, return the additive inverse of each. Each positive becomes negatives, and the negatives become positives. You can assume that all values are integers. Do not mutate the input array/list. Examples:

invert([1,2,3,4,5]) == [-1,-2,-3,-4,-5] invert([1,-2,3,-4,5]) == [-1,2,-3,4,-5] invert([]) == []

Solution by -

My Solution


	function invert(array) {
		return array.map(x => -x);
		}
				

Try it yourself - CodeWars

======= Code Wars - Brett Crafton

Invert values

Question

Given a set of numbers, return the additive inverse of each. Each positive becomes negatives, and the negatives become positives. You can assume that all values are integers. Do not mutate the input array/list. Examples:

invert([1,2,3,4,5]) == [-1,-2,-3,-4,-5] invert([1,-2,3,-4,5]) == [-1,2,-3,4,-5] invert([]) == []

Solution by -

My Solution


	function invert(array) {
		return array.map(x => -x);
		}
				

Try it yourself - CodeWars

>>>>>>> 0e614172debaa009c8d31330edbeb3b765b59c39