Help with App-Undefined

[App Lab - Code.org]

The student keeps getting an Undefined in two places when they try to pull the name from the third input box. Any help would be much appreciated.

The call to updateScreen is on line 6 which means that the if-statement would be checked at the very beginning of the code, before the user has even selected any options. You would only want to check the user if user anything is anything after they have selected it which means that the dropdowns were changed. Also, the assignments for the user data are sequential as well, so the computer will get the text from the dropdowns at the very beginning, which again, doesn’t make sense, since the user, at the very beginning has not selected anything. Those lines of code and the call to update screen should be in onEvents. Lastly, checking if “Not very hungry” == “not very hungry” is false as they are not the same, N capital vs n lowercase… so that is why none of the conditions are true since none of them will match the text from the dropdown. Lastly, the hungry level should be getNumber not getText since it is a numeric. see this fixed code for more clarity: App Lab - Code.org

1 Like