Decision Maker App Help

I am trying to figure out how to change screens on app dependent on the options chosen in a dropdown list. There will be multiple items chosen from the dropdown….

The code is not complete since we can’t figure out why the screen isn’t changing with the conditional at line 38 … we have the variable ingredients being set to the items chosen from the dropdown and then checking the variable in the conditional to change screens… Link to project

Hi @tdean1,

The first thing that I notice is that "eggs on line 36 is missing a second quote - this means that the { at the end of that line is being read as part of the string rather than as the opening bracket of your conditional statement.

The next thing I notice is that the ingredients variable doesn’t actually contain the ingredient by itself. You can see this by adding a few print statements in the method:

This will show you that the ingredients variable actually contains more info which is helpful for formatting on the screen, but not great for your comparison!

You may want to use ingredient.includes(“eggs”) in this space so that you’re able to see if the word is part of the string, but not perfectly equivalent.

You had a couple of issues with this program. The biggest two were how you were testing in the conditional and the scope of your variable. Humans can say, check car against this OR that, in coding we have to be specific. Check car against this OR Check car against that. Have to test the variable against each side of the conditional. If you are going to use a variable around your program, it has to be a global one, yours were all local. You also had an issue with your if/else statement. I would also try to get in a habit of getting your students to put blocks of code in a function, instead of a event handler. I added some screens to make sure it was all moving along as it should (or what I thought you were trying to do).

Let me know if you need me to explain anything else:

We could get it to work with just one ingredient selected, but he wants to be able to select multiple ingredients from the list.

I think this is where the .includes() could come in handy as mentioned in my post above.

I will share that with him tomorrow and see how it goes. Thanks for the input.

I think that would be creating a list and using the .join feature.

Look at the Unit 7: Lesson 2: #2. It sounds like you are trying to do something similar.

Let me know if I am waaay of base here.