Can someone help me with a personality test? (JavaScript) | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

Can someone help me with a personality test? (JavaScript)

Iā€™m trying to make a personality quiz but have hit a dead end (Iā€™m no so good with JavaScript). How can I use the if else statement to change the next question based on the users answer? eg. the quiz is about TV shows: the first question would be ā€œdo you like comedy?ā€, if the answer is ā€œyesā€, it should show ā€œhave you ever watched a sitcom?ā€, though if the answer is ā€œnoā€, than the next question would be ā€œdo violent scenes bother you?ā€.

1st Aug 2020, 5:13 PM
GiuMar
GiuMar - avatar
1 Resposta
+ 1
Not especially from the JavaScript view, but I don't think, you should use if-else-branches at all. If the flow is completely determined, you should rather store all questions as objects, with an attribute pointing to the respective previous answer.
1st Aug 2020, 5:35 PM
Sandra Meyer
Sandra Meyer - avatar