Created
March 24, 2022 15:41
-
-
Save heineiuo/d69616004986cdf8381a6f0ff5e50069 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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