Help with Hogwarts App debug

Link to the project :
What I expect to happen: The App should start with a title screen (Screen1). When you click on the “Get Sorted” button (Button1) it should take you to screen2 which is a series of radio buttons. You choose a radio button and click Next at the bottom of the screen and it should take you to screen3, etc for 10 screens. Then based on your choices a screen should appear showing which house you are in.
What actually happens: It immediately shows the screen of the default House “Ravenclaw”. It does not go to any of the screens.
What I’ve tried: I added “SetScreen” command at the beginning to set the screen to Screen1. But the button click event did not work.


Looks like a fun app! Here’s a little help in debugging.

There’s a lot going on here. First, a few things …On line 9, winner is defined as a string “no winner”, but later on it’s used as an array. It should be defined as an array. var winner = [ ]; Then, if “no winner” should be the first element of the array, you could say "winner[0]="no winner".

This isn’t the reason it’s not working though …

The code is executing and it does show the opening screen (for a brief nano-second) and then continues all the way down until it reaches line and when it reaches line 178 and executes all of the logic, it then chooses screen 13.

What appears to be happening is that your conditionals are all being executed without any buttons being clicked. They should only execute after the input is selected, but the way the code is written, they are independent of the button clicks.

I would suggest perhaps switching to text mode and copying all of the code and pasting it into a text document somewhere.

Then, start at the beginning and start adding code a few lines at a time (pasting it back in) and seeing if you can get the code to only execute when a button is pressed.

Hopefully this will get you started …


Thanks. That helps. I will work on it.

One other observation … I would start the program by assigning the variables a starting value … especially the houses. Right now, they are undefined and in some cases, your code tries to add 1 to a value of undefined (which will likely remain undefined).

In terms of where to put the conditional blocks (the ones adding points to the houses), ask yourself, “when should I check the value of the checkboxes.” Then, put them inside the code checking for the click (if that makes sense).

Good luck!


Thanks for your help with this. I worked on it last Friday and got it working. This has made the third grade developer very happy. Great end to the school year for her.