Skip to content

Instantly share code, notes, and snippets.

@Eatkin
Last active April 19, 2023 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Eatkin/c974e6f25c52d222e7d1a81c9b1cfe00 to your computer and use it in GitHub Desktop.
Save Eatkin/c974e6f25c52d222e7d1a81c9b1cfe00 to your computer and use it in GitHub Desktop.
A horribly inefficient implementation of "hello world!".
const greet = function() {
let greeting = "";
while (greeting !== "hello world!") {
greeting = "h".repeat(Math.ceil(Math.random() * 5));
greeting += "e".repeat(Math.ceil(Math.random() * 5));
greeting += "l".repeat(Math.ceil(Math.random() * 5));
greeting += "o".repeat(Math.ceil(Math.random() * 5));
greeting += " ".repeat(Math.ceil(Math.random() * 5));
greeting += "w".repeat(Math.ceil(Math.random() * 5));
greeting += "o".repeat(Math.ceil(Math.random() * 5));
greeting += "r".repeat(Math.ceil(Math.random() * 5));
greeting += "l".repeat(Math.ceil(Math.random() * 5));
greeting += "d".repeat(Math.ceil(Math.random() * 5));
greeting += "!".repeat(Math.ceil(Math.random() * 5));
}
return greeting;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment