Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to repeat the same javascript over again for my html5 app?
    text
    copied!<p>I need some help with my html5 application. The works the following: A random word is shown up. Then you need to click the right button to answer. If you are correct the counter must go +1, if incorrect the counter must go -1. Then the next word has to show up. When the counter has become a certain number, e.g. 20, you have finished the course. </p> <p>I tried to use a for loop, but I didn't get it working. Help me please..</p> <pre><code>&lt;script type="text/javascript"&gt; var accusative = ["bis", "durch", "für", "gegen", "ohne", "um", "entlang"]; var dative = ["aus", "bei", "mit", "nach", "seit", "von", "zu", "entgegen", "außer", "gegenüber", "an...vorbei"]; var choicePreposition = ["an", "auf", "hinter", "neben", "in", "über", "unter", "vor", "zwischen"]; var answer2; var caseDeterminar = Math.floor((Math.random()*3)); function question(){ if (caseDeterminar === 0) { determinar = dative[Math.floor((Math.random()*11))]; } else if (caseDeterminar === 1) { determinar = accusative[Math.floor((Math.random()*7))]; } else { determinar = choicePreposition[Math.floor((Math.random()*9))]; } return determinar; } function answerIsDative() { var answer1 = "3" if (answer1 === answer2) { prompt("good!"); } else { prompt("wrong!"); } } function answerIsAccustive() { var answer1 = "4" if (answer1 === answer2) { prompt("good!"); } else { prompt("wrong"); } } function answerIsChoice() { var answer1 = "k" if (answer1 === answer2) { prompt("good!"); } else { prompt("wrong!"); } } document.write(question()); if (caseDeterminar === 0) { answer2 = "3"; } else if (caseDeterminar === 1) { answer2 = "4"; } else if (caseDeterminar === 2) { answer2 = "k"; } if (i === 10) { prompt("You are done!!"); } //} &lt;/script&gt; &lt;/p.woord&gt; &lt;/span&gt; &lt;/div&gt; &lt;div id="buttons"&gt; &lt;button type="button" id="dative" onClick="answerIsDative()"&gt; Dative &lt;/button&gt; &lt;button type="button" id="accusative" onClick="answerIsAccustive()"&gt; Accusative &lt;/button&gt; &lt;button type="button" id="choice" onClick="answerIsChoice()"&gt; Choice &lt;/button&gt; &lt;/div&gt; &lt;script type="text/javascript"&gt; document.write(i); &lt;/script&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload