I have encountered a strange problem,
Code:
document.getElementById("insertWord").innerHTML="please translate the word "+toTranslate[i]+"to french ";
Does anyone know why when I put a space at the beginning of the string " to french" i does not change but when i remove the space everything works as expected.
here is the rest of my code.
Code:
var score=0;
var i =0;
var toTranslate=new Array("hello","car","apple","dog","fish");
var reponse=new Array("bonjour","voiture","pomme","chien","poisson");
function questions() {
var str =document.getElementById("inputbox").value;
var trimmed = str.replace(/^\s+|\s+$/g, '') ;
var trimmedl = trimmed.toLowerCase();
if (trimmedl ==reponse[i]) {
alert(trimmedl+" is correct");
score++;
}else {
alert("i am sorry to say that is incorect");
}
i = Math.floor(Math.random() * (1 - 0+ 1)) + 0;
document.getElementById("score").innerHTML="your score is "+score;
document.getElementById("insertWord").innerHTML="please translate the word "+toTranslate[i]+"to french yay";
}
function win() {
alert(score);
}