dimanche 7 juin 2015

Adding the OR operator to a quizz form makes it accept any answers

I'm having a weird problem when trying to create a question form that is validated with Javascript:

If I write my validation like this:

if (typedValue === "myAnswer" && clearedLevels === 1){doStuff}

Everything works. But I want to create several correct answers, so I write:

 if (typedValue === "myAnswer"||"secondAnswer" && clearedLevels === 1){doStuff}

..and all of a sudden anything written to the input form is accepted as the answer.

Aucun commentaire:

Enregistrer un commentaire