I've created two arrays, one with questions and one with answers.
Follow the template.
perguntas[0] = "que sao dinossauros";
respostas[0] = ["Constituem um grupo de diversos animais membros do clado Dinosauria"];
perguntas[1] = "tipos de dinossauros que existiram";
respostas[1] = ["Terópodes, Saurópodes, Ceratopsídeos, Ornitópodes, Estegossauros, Anquilossauros,Paquicefalossauros"];
Well, I need to make sure that I find out if a given text is contained in that array, knowing what position it found, so I can return a response.
I tried the following way.
if( $.inArray(pergunta, perguntas[i]) !== -1 ){
alert("encontrei");
}else{
alert("não encontrado");
};
So it works, but I need to figure out which position was found to send a return.
I created a replay to identify where it was found, but it never finds the text.
for(var i = 0; i < perguntas.length; i++){
if( $.inArray(pergunta, perguntas[i]) !== -1 ){
alert("encontrei");
}else{
alert("não encontrado");
};
}
Thank you