← Back to TIL

JS Array Methods

Short Notations

Today I was solving a code puzzle on codewars where I was writing

export const invert = (array: number[]) => array.map(n => n * -1);

Instead could be written like below

export const invert = (array: number[]) => array.map(n => -n);