Skip to content

Instantly share code, notes, and snippets.

@hemedani
Created November 2, 2022 07:01
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/94cef4f55d19ec8434ed4cca534da231 to your computer and use it in GitHub Desktop.
Save hemedani/94cef4f55d19ec8434ed4cca534da231 to your computer and use it in GitHub Desktop.
create number from an array
const arr = [5, 6, 5, 4, 7, 8];
const nums = arr.reduce(
(current, next) => (current * 10) + next,
0,
);
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