Red to linuxmemesEnglish • 9 months agoCode interviews for a PHP developer rolesreddthat.comimagemessage-square128fedilinkarrow-up1350arrow-down122
arrow-up1328arrow-down1imageCode interviews for a PHP developer rolesreddthat.comRed to linuxmemesEnglish • 9 months agomessage-square128fedilink
minus-square@basdiljhslink14•9 months agofor(var i=0;i<=100;i++){ if((i%2)==1) console.log(i); } btw % is the modulo operator, x%y returns the remainder of division of x by y
minus-square@[email protected]linkfedilink5•9 months agoThank you holy shit I was beginning to think no one has ever seen a fizz buzz before
minus-squareLostXORlinkfedilink4•9 months agoSlightly simpler, start at 1 and increment by 2 so you don’t have to check whether i is odd. for (var i = 1; i < 100; i += 2) { console.log(i); }
minus-squareJeenalinkfedilink3•9 months agoStrictly speaking this one does not find the odd numbers, it just prints them.
for(var i=0;i<=100;i++){ if((i%2)==1) console.log(i); }
btw % is the modulo operator, x%y returns the remainder of division of x by y
Thank you holy shit I was beginning to think no one has ever seen a fizz buzz before
Slightly simpler, start at 1 and increment by 2 so you don’t have to check whether i is odd.
for (var i = 1; i < 100; i += 2) { console.log(i); }
Strictly speaking this one does not find the odd numbers, it just prints them.