Created
March 29, 2022 16:15
-
-
Save anonymoustafa/c305942d1b49cffcdd65e12fcd873109 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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