Skip to content

Instantly share code, notes, and snippets.

@heineiuo
Created March 24, 2022 15:41
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 heineiuo/d69616004986cdf8381a6f0ff5e50069 to your computer and use it in GitHub Desktop.
Save heineiuo/d69616004986cdf8381a6f0ff5e50069 to your computer and use it in GitHub Desktop.
function n(lit) {
const [str] = lit
const [start, end] = str.split('..').map((item) => parseInt(item))
return Array.from({ length: end - start + 1 }, (v, k) => k + start)
}
console.log(n`1..8`) // [1,2,3,4,5,6,7,8]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment