// Model Variabler let words = ["green", "red", "cat", "man", "stared", "jumped", "pool", "wall"]; let word1 = '__ '; let word2 = '__ '; let word3 = '__ '; let word4 = '__ '; let sentence = "Once there was " + word1 + " " + word2 + " that " + word3 + " in the " + word4 + " - and great things happened. The End"; // View // HTML, onclick CSS updateView(); function updateView() { let html = `
${sentence}
${words[0]}
${words[1]}
${words[2]}
${words[3]}
${words[4]}
${words[5]}
${words[6]}
${words[7]}
`; document.getElementById('app').innerHTML = html; }; // Controller endrer modellen function insertWords1(word) { word1 = word; sentence = "Once there was " + word1 + " " + word2 + " that " + word3 + " in the " + word4 + " - and great things happened. The End"; document.getElementById('sentence').innerHTML = sentence; updateView(); } function insertWords2(word) { word2 = word; sentence = "Once there was " + word1 + " " + word2 + " that " + word3 + " in the " + word4 + " - and great things happened. The End"; document.getElementById('sentence').innerHTML = sentence; updateView(); } function insertWords3(word) { word3 = word; sentence = "Once there was " + word1 + " " + word2 + " that " + word3 + " in the " + word4 + " - and great things happened. The End"; document.getElementById('sentence').innerHTML = sentence; updateView(); } function insertWords4(word) { word4 = word; sentence = "Once there was " + word1 + " " + word2 + " that " + word3 + " in the " + word4 + " - and great things happened. The End"; document.getElementById('sentence').innerHTML = sentence; updateView(); }