Last active
November 4, 2021 07:57
-
-
Save benjifriedman/6ed4968438fd7fd53698c532b0e0d332 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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