Changed around line 1
+ const wordList = ["above", "active", "afraid", "after", "ago", "Alaska", "all", "also", "always", "amazing", "American", "and", "angry", "animal", "ant", "any", "anything", "apple", "April", "aren't", "are not", "arm", "art", "room", "ask", "at", "ate", "attention", "August", "aunt", "autumn", "baby", "bad", "badminton", "bag", "ball", "bamboo", "banana", "basket", "basketball", "bathroom", "be careful", "beach", "bear", "beautiful", "because", "become", "bed", "bedroom", "beef", "before", "behind", "beside", "best", "better", "between", "big", "bigger", "bike", "bird", "black", "blackboard", "blue", "boat", "boating", "body", "book", "bookstore", "both", "bottle", "bought", "bowl", "box", "boy", "bread", "breakfast", "breath", "bridge", "broken", "brother", "brown", "building", "bunny", "bus", "businessman", "busy", "but", "buy", "by", "cake", "camp", "Canada", "Canadian", "Canberra", "candy", "cap", "car", "carrot", "cartoon", "cat", "cave", "chair", "chase", "cheap", "cheetah", "chicken", "children", "China", "Chinese book", "chocolate", "chopsticks", "Christmas", "cinema", "class", "classroom", "clean", "clean my room", "cleaned", "clever", "climbing", "clock", "clothes", "cloudy", "club", "coach", "coat", "cold", "come on", "comic", "comic book", "computer", "computer room", "contest", "cook", "cooking", "cool", "could", "count", "count to ten", "country", "countryside", "cousin", "cow", "crayon", "crossing", "cute", "cycling", "dad", "dance", "dancing", "day", "dear", "December", "deep", "degree", "delicious", "desk", "diary", "dictionary", "different", "dining hall", "dinner", "dinosaur", "dirty", "do", "do homework", "do kung fu", "do morning exercises", "doctor", "dog", "doing morning exercises", "dollar", "door", "down", "drank", "draw", "draw cartoons", "dream", "dress", "drink", "drinking", "driver", "duck", "each", "each other", "ear", "early", "Easter", "easy", "eat", "eat breakfast", "eat dinner", "eating", "eating lunch", "egg", "eight", "eighteen", "eighty", "elephant", "eleven", "else", "email", "English book", "English class", "enjoy", "eraser", "evening", "every", "everyone", "everywhere", "excited", "exercise", "exhibition", "expensive", "eye", "face", "factory", "fall", "family", "fan", "far", "farm", "farmer", "fast", "faster", "fat", "father", "favourite", "feature", "February", "feel", "fell", "felt", "ferry", "few", "fifteen", "fifth", "film", "find", "finish", "first", "first floor", "fish", "fisherman", "five", "fixed", "floor", "flower", "fly", "follow", "food", "fool", "foot", "football player", "forest", "fork", "forty", "four", "fourteen", "fourth", "fresh", "Friday", "fridge", "friend", "friendly", "front", "fruit", "funny", "fur", "game", "garden", "gave", "Germany", "get", "get together", "get up", "gift", "giraffe", "girl", "glasses", "glove", "go boating", "go cycling", "go for a walk", "go home", "go on a picnic", "go shopping", "go swimming", "go to bed", "go to school", "goal", "goat", "good job", "GPS", "grandfather", "grandma", "grandmother", "grandpa", "grandparent", "grape", "grass", "green", "green beans", "gym", "had", "had a cold", "hair", "half", "hall", "hamburger", "hand", "happy", "hard-working", "hat", "have a look", "have class", "having ... class", "he", "head", "head teacher", "healthy", "hear", "heavier", "helmet", "help", "help yourself", "helpful", "hen", "her", "hers", "high", "hiking", "him", "his", "hobby", "holiday", "homework", "horse", "hospital", "hot", "hotel", "house", "how about", "how much", "hurry up", "hurt", "ice cream", "ice-skate", "idea", "if", "ill", "in", "in front of", "interesting", "internet", "island", "Italian", "its", "jacket", "January", "jasmine", "job", "join", "juice", "July", "jumping", "June", "just", "just a minute", "keep", "keep to the right", "keep your desk clean", "key", "kid", "kilogram", "kind", "kitchen", "kite", "kitten", "knife", "know", "kung fu", "Labour Day", "lake", "lamp", "last", "late", "laughed", "leaf", "learn", "left", "leg", "lesson", "letter", "library", "licked", "light", "like", "listening to music", "little", "live", "living room", "London", "long", "longer", "look for", "look up", "lost", "lot", "lots of", "loud", "love", "lovely", "lower", "lunch", "magazine", "make a snowman", "man", "map", "March", "maths book", "May", "meet", "metre", "mice", "Mid-Autumn Festival", "milk", "mine", "Monday", "monkey", "moon", "mooncake", "more", "Moscow", "mother", "mountain", "mouse", "mouth", "move", "Mrs", "Ms", "mud", "mule", "mum", "Munich", "museum", "music class", "music room", "must", "national", "National Day", "nature", "near", "need", "new", "New York", "next", "next to", "next week", "nice", "nine", "nineteen", "no", "no problem", "noise", "noodles", "nose", "notebook", "nothing", "November", "now", "nurse", "o'clock", "October", "of course", "off", "often", "OK", "old", "older", "on", "on foot", "one", "onion", "open", "or", "orange", "other", "our", "ours", "outside", "over", "p.m.", "pack", "paint", "panda", "pants", "Papa Westray", "parents", "park", "part", "party", "pass", "pay attention to", "PE class", "pear", "pen", "pen pal", "pencil", "pencil box", "people", "phone", "photo", "pick", "pick apples", "picnic", "picture", "pig", "pilot", "ping-pong", "pink", "pizza", "plane", "plant", "plate", "play", "play basketball", "play football", "play ping-pong", "play sports", "play the pipa", "playground", "playing", "poem", "police officer", "polite", "post office", "postcard", "postman", "potato", "pretty", "price", "problem", "pull", "pupil", "puppy", "puzzle", "quickly", "quiet", "rabbit", "race", "rainy", "read", "read books", "reading a book", "ready", "really", "red", "reporter", "restaurant", "rice", "right", "river", "robot", "rode", "roll", "RSVP", "ruler", "sad", "salad", "sale", "sandwich", "Saturday", "saw", "say", "scarf", "schedule", "school", "schoolbag", "science", "scientist", "Scotland", "sea", "season", "second", "second floor", "secretary", "see a doctor", "see a film", "send", "September", "seven", "seventeen", "shadow", "shall", "share", "she", "sheep", "ship", "shirt", "shoe", "shop", "short", "shorter", "shorts", "should", "show", "shy", "sing", "sing English songs", "Singapore", "sir", "sister", "sit", "six", "sixteen", "size", "skirt", "sled", "sleeping", "slept", "slow", "slow down", "small", "smaller", "smarter", "snow", "snowman", "snowy", "so", "so much", "sock", "sofa", "sometimes", "song", "sound", "soup", "space", "Spain", "Spanish", "speak", "speak English", "special", "spoon", "sport", "sports meet", "spring", "star", "start", "stay", "stayed", "still", "stop", "storybook", "straight", "strawberry", "street", "strict", "strong", "stronger", "stuck", "student", "studies", "study", "subway", "summer", "Sunday", "sunglasses", "sunny", "supermarket", "sure", "sushi", "sweater", "sweet", "swim", "Sydney", "table", "tail", "take", "take a dancing class", "take a deep breath", "take a trip", "take turns", "talk quietly", "tall", "taller", "taxi", "tea", "teach", "teacher", "teacher's desk", "teachers' office", "tell", "ten", "than", "Thanksgiving", "The Great Wall", "their", "theirs", "them", "there", "these", "thin", "thing", "thinner", "third", "thirsty", "thirteen", "thirtieth", "thirty", "those", "thought", "three", "Thursday", "tiger", "till", "tired", "today", "together", "tomato", "tomorrow", "tonight", "too", "took", "took pictures", "toy", "traffic", "traffic lights", "train", "travel", "tree", "trip", "try", "try on", "Tuesday", "turn", "Turpan", "TV", "twelfth", "twelve", "twentieth", "twenty", "twenty-first", "twenty-third", "two", "type", "UK", "umbrella", "uncle", "under", "university", "us", "USA", "use", "usually", "vacation", "vegetable", "village", "visit", "wait", "walk", "wall", "want", "warm", "wash", "wash my clothes", "washed", "watch", "watch TV", "watched", "water", "water bottle", "watermelon", "way", "wear", "weather", "Wednesday", "weekend", "well", "we'll = we will", "went", "went camping", "went fishing", "when", "which", "white", "whose", "why", "will", "win", "window", "windy", "winter", "woke", "woman", "wonderful", "word", "word book", "work", "worker", "world", "worried", "worry", "wow", "wrong", "year", "yellow", "yesterday", "young", "younger", "your", "yours", "yum", "zoo"];
+
+ let lastWord = '';
+ let isPlayerTurn = true;
+
+ document.getElementById('submit-word').addEventListener('click', function() {
+ const userWord = document.getElementById('word-input').value.toLowerCase();
+ if (isValidWord(userWord)) {
+ lastWord = userWord;
+ document.getElementById('word-display').textContent = `Last word: ${lastWord}`;
+ document.getElementById('result').textContent = '';
+ isPlayerTurn = false;
+ setTimeout(computerTurn, 1000);
+ } else {
+ document.getElementById('result').textContent = 'Invalid word or not in the list!';
+ }
+ document.getElementById('word-input').value = '';
+ });
+
+ function isValidWord(word) {
+ if (!wordList.includes(word)) return false;
+ if (lastWord && word[0] !== lastWord[lastWord.length - 1]) return false;
+ return true;
+ }
+
+ function computerTurn() {
+ const possibleWords = wordList.filter(word => word[0] === lastWord[lastWord.length - 1]);
+ if (possibleWords.length > 0) {
+ const computerWord = possibleWords[Math.floor(Math.random() * possibleWords.length)];
+ lastWord = computerWord;
+ document.getElementById('word-display').textContent = `Last word: ${lastWord}`;
+ isPlayerTurn = true;
+ } else {
+ document.getElementById('result').textContent = 'Computer cannot find a word. You win!';
+ }
+ }