Unit 4 project coding question

[Posts in the debugging category need to have the following pieces of information included in order to help other teachers or our moderator team best help you. Feel free to delete everything in brackets before posting your request for debugging help.]

Link to the project or level: [https://studio.code.org/projects/applab/yQJN-30vq2v47MjOHc1bVh43bPopRKrdVfDxuw9Scds]
What I expect to happen: [This is a student project for Unit 4 that is not complete, but that I have questions about before I can help them proceed]
What actually happens: [The code works to some extent, but does not provide the expected response when answers are input for level of education and citizenship.]
What I’ve tried: [nothing yet. I’m unsure why it doesn’t work, but I wonder if it’s because of the setup of the conditionals in the function. Should they be separate conditionals, or a longer sequence of if/else statements? The student also has some extra onEvent blocks that are incomplete at the bottom.
They are still working on it, but I need to have a plan of what to recommend to them on Friday.]

What sequence of input makes you think it doesn’t work?

Hi @erogers,

It looks like this is an issue relating to the possible actions in the event block. Right now, your student is using the getText command as soon as the dropdown is clicked on - however at this point the user hasn’t chosen anything from the dropdown so nothing new is stored. Because your students are using a ‘submit’ button, there are two possible solutions to this issue:

  • Update the action that triggers the event
  • Don’t trigger the event when the dropdown is changed, only collect the data when the submit button has been pressed.

Documentation about these two options to share with your student can be found in the two different on-event code segments of the Examples section of the App Lab API. To access it:

  1. Go to the toolbox and hover over ‘dropdown’
  2. Click on the “show examples” button that appears in the bottom right of the blue box
  3. Scroll to “examples” in the pop-up window.

When I chose college degree and U.S. citizen, it returned the message “Sorry, you must have at least a high school diploma…”

Thank you for the explanation. I will tell them to try that.