Skip to content

Instantly share code, notes, and snippets.

@ChrisDobby
Created January 31, 2023 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisDobby/7d8d03b4590672949fc455fa9085bd05 to your computer and use it in GitHub Desktop.
Save ChrisDobby/7d8d03b4590672949fc455fa9085bd05 to your computer and use it in GitHub Desktop.
Given a positive integer, generate an array in which every element is an array that goes from 1 to the index of that array.
const generateArrays = (n: number) => Array.from({ length: n }, (_, index) => Array.from({ length: index + 1 }, (_, innerIndex) => innerIndex + 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment