Skip to content

Instantly share code, notes, and snippets.

@hemedani
Last active November 2, 2022 06:58
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 hemedani/9b1bceff33387ba27251efbf87aa9d42 to your computer and use it in GitHub Desktop.
Save hemedani/9b1bceff33387ba27251efbf87aa9d42 to your computer and use it in GitHub Desktop.
create number from an array
const arr = [5, 6, 5, 4, 7, 8];
const nums = eval(arr.map((number, index, arr) => number * 10 ** (arr.length - 1 - index)).join("+"));
console.log("the final number is ", nums);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment