Skip to content

Instantly share code, notes, and snippets.

@jose-mdz
Created October 11, 2022 18:04
Show Gist options
  • Save jose-mdz/536421e97888a5f38b6ae173154acbfe to your computer and use it in GitHub Desktop.
Save jose-mdz/536421e97888a5f38b6ae173154acbfe to your computer and use it in GitHub Desktop.
Rows & Cols
const getIndex = (row: number, col: number, width: number) => width * row + col;
const getRowCol = (index: number, width: number) => [Math.floor(index / width), index % width];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment