Skip to content

Commit

Permalink
HIDING WORD FROM HINT
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Smith committed Jun 20, 2023
1 parent bfca4fa commit d6c22e3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions js/functionality.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ function startGame() {
wordDef = JSON.stringify(words[randomNum]).split(":");
wordPrep = wordDef[0].substring(2, wordDef[0].length - 1).trim().replaceAll(" ", "-").replaceAll("'", "");
definitionPrep = wordDef[1].substring(1, wordDef[1].length - 2).replaceAll("'", "");
const wordLower = wordPrep.toLowerCase();
/*HIDING WORD FROM HINT*/
function capitalizeFirstLetter(str) {
return str[0].toUpperCase() + str.slice(1);
}
while (definitionPrep.indexOf(wordLower) !== -1) {
definitionPrep = definitionPrep.replace(wordLower, "~~~~~~");
}
while (definitionPrep.indexOf(capitalizeFirstLetter(wordLower)) !== -1) {
definitionPrep = definitionPrep.replace(capitalizeFirstLetter(wordLower), "~~~~~~");
}
/*END HIDING WORD FROM HINT*/

for (let i = 0; i < wordPrep.length; i++) {/*remeber to check for spaces*/
let addThis = " ~ ";
Expand Down

0 comments on commit d6c22e3

Please sign in to comment.