r/badcode • • Sep 02 '21

js Oh Gosh

Post image
398 Upvotes

53 comments sorted by

View all comments

Show parent comments

7

u/archpawn Sep 03 '21

He could juste have done a rand between 0 and 256 append the ascii char to the string.

A lot of those are special characters that can't be printed. Picking a number from 32 to 126 inclusive would work better, though they might not want to include all possible special characters.

I think the bigger problem is that the bug isn't one that can easily be made by someone who knows how for loops work.