Unit 5 Lesson 15 Extension Activity App


The student code posted above doesn’t return the correct recommendations for Unit 5, Lesson #15, and I can’t find the logic error. Is anybody willing to look at it to see if you can see the error? Thanks if you can help!!

Hi Sonja,

Can you give specific examples of when it’s not giving the correct recommendation? I played it, and everything seemed fine, but I have no idea which recommendation is “correct” in the app.


Hi Elizabeth,

As an example, the student intended for his algorithm to recommend purchasing a
sedan, when the user preferred a small,
luxury vehicle for in the city. He has his recommendations in the correct order for that, but instead the app returns an
SUV. It does something similarly wrong for every recommendation.

Thanks for responding so quickly!


and Equip Every Child with Every
Opportunity Every Day”

S. Harris

Science Teacher, M.Ed.

Hi Sonja,

There are two things going on. First, the student needs to pass in the entire list of car types every time he calls the “recommend” function. Right now it’s not clear to me why sometimes the list is different (see lines 70, 75, 81, and 88). Second, the order of the car names in that list needs to be the same as the numerical order of the screens, which is “[Sedan, SUV, Truck, Minivan]”.

I think that the program will work if you replace the code in the lines I referenced with recommend([Sedan, SUV, Truck, Minivan]);

The code is a little tricky, because it goes beyond what we expect students to know, and if kids mess it up, it’s hard to recover. They don’t quite know enough to make a recommender app on their own. The good news is that the student did a great job with all the code that is in the scope of the course.


1 Like

Thank you so much!

Sonja S. Harris

Business Education

McCracken Middle School

300 Webber Road

Spartanburg, SC 29307