Skip to content

Instantly share code, notes, and snippets.

@theohogberg
Last active July 19, 2025 23:34
Show Gist options
  • Save theohogberg/7db204aba884bbcfcb269f272903bb0e to your computer and use it in GitHub Desktop.
Save theohogberg/7db204aba884bbcfcb269f272903bb0e to your computer and use it in GitHub Desktop.
Generate a random number in JavaScript (One-Liner) between 0 - 255; forces the resulting float into an integer due to how js converts values on bitwise ops
// random number between 0 - 255
Math.random()*256|0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment