cm0002@lemmy.zip to Programmer Humor@programming.dev · 5 days agoMore code = more betterlemmy.zipexternal-linkmessage-square93fedilinkarrow-up1650arrow-down116
arrow-up1634arrow-down1external-linkMore code = more betterlemmy.zipcm0002@lemmy.zip to Programmer Humor@programming.dev · 5 days agomessage-square93fedilink
minus-squareOshaqHennessey@midwest.sociallinkfedilinkarrow-up63·5 days agofunction myFunction() { try { x = new Random().nextInt(); if (x != 10) { throw "not 10"; } else { return (10) } catch(err) { myFunction() } } } x = myFunction() Commit notes: Added error handling
minus-squarefirewallfail@lemmy.worldlinkfedilinkarrow-up62·5 days agoReturning 10 instead of x when x finally ends up being 10 really ties it together.
minus-squareOshaqHennessey@midwest.sociallinkfedilinkarrow-up28·5 days agoI’m glad you noticed. That was my favorite part too.
minus-squareNιƙƙιDιɱҽʂ@lemmy.worldlinkfedilinkarrow-up4·5 days ago SyntaxError: Unexpected token ‘catch’
function myFunction() { try { x = new Random().nextInt(); if (x != 10) { throw "not 10"; } else { return (10) } catch(err) { myFunction() } } } x = myFunction()Commit notes: Added error handling
Returning 10 instead of x when x finally ends up being 10 really ties it together.
I’m glad you noticed. That was my favorite part too.
Coding on mobile is hard