Hello! I need help fixing a student’s issue…see below…
The purpose of this app is to help the user choose what type of dog they should adopt based on size and breed group. After the user chooses the size and breed group and clicks enter, the app will display a random name and random picture that match the size and breed group they have chosen in the previous screen. But sometimes the result is “undefined”. Like if you choose “Small” and “Toy”, the result will be undefined since there isn’t a dog breed from the table that matches both of the requirements.
So what I’m trying to do is make the screen display “Sorry. Please choose again” whenever the result is undefined. This is the code the student wrote, but it does not work:
var output = getText(“dogOutput”);
if(output != filteredNames[randomIndex]){
setText(“dogOutput”, “Sorry. Please try again.”);
}
Here is a link to the student’s app: