Skip to content

Instantly share code, notes, and snippets.

@rinchik
Last active November 3, 2020 15:57
Show Gist options
  • Save rinchik/b93b5067456ee7f2ea4686571dfb3991 to your computer and use it in GitHub Desktop.
Save rinchik/b93b5067456ee7f2ea4686571dfb3991 to your computer and use it in GitHub Desktop.
const makeCoordinatesZeroBased = rawCoordinates => Object.entries(rawCoordinates)
.reduce((processedCoordinates, [coordinate, value]) => {
const isCoordinateValid = typeof value === 'number';
let updatedValue = value;
if (isCoordinateValid)
updatedValue = value - 1;
processedCoordinates[coordinate] = updatedValue;
return processedCoordinates;
}, {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment