Pure Functions
by LyndseyB
Babel + JSX
const array = [1, 2, 3, 4, 5];
const reverseArray = (array) => {
// pure because we're creating a new array from array
// and not mutating the original array
return [...array].reverse();
};
const reversed = reverseArray(array);
console.log(reversed);
console.log(array);