cm0002@lemmy.zip to Programmer Humor@programming.dev · 17 hours agoMore code = more betterlemmy.zipimagemessage-square53fedilinkarrow-up1449arrow-down19
arrow-up1440arrow-down1imageMore code = more betterlemmy.zipcm0002@lemmy.zip to Programmer Humor@programming.dev · 17 hours agomessage-square53fedilink
minus-squareOshaqHennessey@midwest.sociallinkfedilinkarrow-up40·11 hours 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-up34·10 hours agoReturning 10 instead of x when x finally ends up being 10 really ties it together.
minus-squareOshaqHennessey@midwest.sociallinkfedilinkarrow-up16·10 hours agoI’m glad you noticed. That was my favorite part too.
minus-squareNιƙƙιDιɱҽʂ@lemmy.worldlinkfedilinkarrow-up2·10 hours 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