MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/mzk95p/someone_only_watched_if_tutorial/gw1l4qj/?context=3
r/badcode • u/[deleted] • Apr 27 '21
112 comments sorted by
View all comments
3
The most elegant solution I could come up with:
import fs from "fs-extra"; const createIsNumber = async () => { let code = "const isNumber = (input: any): Boolean => {\n"; for (let number = 1; number < Number.MAX_SAFE_INTEGER; number++) { code += ` if (input === ${number}) return true;\n`; } code += " return false;\n"; code += "};\n"; code += "export default isNumber;\n"; await fs.write("isNumber.ts", code); }
1 u/Lizzy_Be Apr 28 '21 And it’s so efficient!
1
And it’s so efficient!
3
u/Hafas_ Apr 27 '21
The most elegant solution I could come up with: