🚀 30 Days of JavaScript – Day 9 Continuing my journey to improve my JavaScript logical thinking by building small interactive programs every day. 💡 Today’s Mini Project: Word Scramble Game 🧩 In this game, the program selects a random word, scrambles its letters, and the user must guess the correct word. If the guess is wrong, the program asks the user to try again. After the correct answer, the user can choose to play again with a new word. 🧠 Concepts Used: Arrays Math.random() split(), sort(), join() while loop Conditional logic 📌 Example Scrambled Word → gcodni Correct Answer → coding 🎥 Demo below 👇 Full source code in the First comment. #JavaScript #WebDevelopment #CodingJourney #ProblemSolving #LearningJavaScript #30DaysOfCode

let words = ["javascript", "coding", "developer"]; let originalWord = words[Math.floor(Math.random() * words.length)]; let scrambled = originalWord  .split("")  .sort(() => Math.random() - 0.5)  .join(""); let guess = prompt("Unscramble the word: " + scrambled); while (guess !== originalWord) {  guess = prompt("Wrong! Try again: " + scrambled); } alert("Correct! The word is: " + originalWord); let playAgain = confirm("Play again?"); if (playAgain) {  location.reload(); } else {  alert("Thanks for playing!"); }

Like
Reply

To view or add a comment, sign in

Explore content categories