jeudi 28 janvier 2016

French Quiz Not Working

I have made a french quiz but it is not working.

Here is the code:

<html>
<head>
<title>Quiz</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1>Quiz</h1>
<p id="one"></p>
<input id="aone" />
<br>
<a href="#" class="myButton" id="btn">Mark It</a>
<script>
var verbs = ["accompagner","aider","aimer","apporter","chanter","danser","coûter","écouter","étudier","fermer","jouer","laver","marcher","montrer","oublier","passer","penser","préparer","raconter","agir","bâtir","choisir","désobéir","finir","guérir","nourrir","obéir","punir","réfléchir","remplir","réussir","rougir","saisir","attendre","défendre","descendre","entendre","interrompre","perdre","rendre","répondre","rompre","vendre"];
var verb = verbs[Math.floor(Math.random() * verbs.length)];
if(verb.slice(-2) == "er") {
var newverb = verb.substring(0, verb.length - 2);
newverb += "es";
}
if(verb.slice(-2) == "ir") {
var newverb = verb.substring(0, verb.length - 2);
newverb += "is";
}
if(verb.slice(-2) == "re") {
var newverb = verb.substring(0, verb.length - 2);
newverb += "s";
}
document.getElementById("one").innerHTML = verb;
document.getElementById("btn").onclick = function () {
if (document.getElementById("aone").value==newverb) { // Not Working.
alert("Correct");
}
}
</script>
</body>
</html>

I think I have traced the problem to the final if statement not being true but I don't understand why. All help will be appreciated.

Aucun commentaire:

Enregistrer un commentaire