Skip to content

Instantly share code, notes, and snippets.

@benjifriedman
Last active November 4, 2021 07:57
Show Gist options
  • Save benjifriedman/6ed4968438fd7fd53698c532b0e0d332 to your computer and use it in GitHub Desktop.
Save benjifriedman/6ed4968438fd7fd53698c532b0e0d332 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Letter Replace</title>
<style>
body {
padding: 50px;
font-family: sans-serif;
}
</style>
</head>
<body>
<p id="result"></p>
<script>
let result = document.querySelector("#result");
let resultText = "";
let inputText = "benji friedman";
let alphabet = "zyxwvutsrqponmlkjihgfedcba";
//let alphabet = "!@#$%*&";
let alphabetsplit = alphabet.split("");
for (let k = 0; k < alphabet.length; k++) {
let replaceCharacter = alphabetsplit[k];
for (let j = 0; j < 153; j++) {
let current = inputText;
let currentArray = current.split("");
for (let i = 0; i < current.length; i++) {
let coinFlip = parseInt(Math.floor(Math.random() * 5));
if (coinFlip == 0) {
currentArray[i] = replaceCharacter;
}
}
let wordAgain = currentArray.join("");
result.innerHTML += wordAgain + " ";
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment