Store the tree as data, and then your code can be very small. If we change the answer given by @ jam6549, we can come up with something like this:
var answer = [ {t: "Does it have fur?", y: 1, n: 2}, {t: "Is it a kitten?", y: 3, n: 4}, {t: "Is it a goldfish?", y: 5, n: 4}, {t: "Found a kitten", y: -1, n: -1}, {t: "I'm stumped", y: -1, n: -1}, {t: "Found a goldfish", y: -1, n: -1} ]; var state = 0; while ( answer[state].y >= 0 ) { var choice = confirm(answer[state].t); state = choice? answer[state].y: answer[state].n; } alert(answer[state].t);
This only supports simple y / n answers, so I can use confirmation, you will want to use an array with a record for every possible answer.
You say that some of the questions are repeated, so I will be tempted to have an array with each unique question text. Your answer array then stores the index in the question array to preserve duplicate text.
source share