Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save anonymoustafa/c305942d1b49cffcdd65e12fcd873109 to your computer and use it in GitHub Desktop.
Save anonymoustafa/c305942d1b49cffcdd65e12fcd873109 to your computer and use it in GitHub Desktop.
// Link to main question ==> https://twitter.com/Loc0m0/status/1508697606716764162?s=20&t=Ziozpzj6KIznNArdT9n3xQ
const splicer = function () {
let accumulator = "";
for (let i = 1; i <= 100_000; i++) {
accumulator = accumulator + "0" + i.toString();
}
let arrayOfStrings = accumulator.split("0");
let arrayOfNumbers = arrayOfStrings.map(Number);
let result = arrayOfNumbers.reduce((sum, current) => sum + current, 0);
console.log(result);
};
splicer();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment