Little problem with Javascript


#1

Hey everyone,
An hour ago i began javascript lessons, and now, the exercice is to find my name in a text.
But when i click the " verify your answer" button, the page freeze, and i can only close it. Am i the only one with that problem ? Do anyone have a solution ?
Thanks


#2

Seems like your having an infinite loop. Could you post your code? Also pls press the Q&A button on the specific exercise this makes it easier to identify the exercise your working on than just using the javaScript categorie.


#3

var texte = "Je vais chercher du pain a la boulangerie antoine viens avec moi"

var monNom = "antoine"

var trouve = []

for ( var i = 0; i = texte.length; i++){

}
here is my code, but even when i change it, nothing happen.
thanks for the advice, never had any problems before, didn't know what to do


#4

This part of your for loop seems to be the problem. What it should do is to check whether i < texte.length which means check if you're not already at the last letter of the text. But what it does is that it assigns the length of your text to i. I don't want to count but I assume that it is more than 0 and any number except 0 is treated as true when used in a condition. So to get rid of the freezing you need to adjust this condition.


#5

oh yeah just changed it, it's good, thanks !