Skip to content

Instantly share code, notes, and snippets.

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