https://studio.code.org/projects/applab/Hc9P70x3vCFQp9dtKZvFT_UT6ushhzbjcmAbVItjli4/edit
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.
Thanks,
Elizabeth
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!

"Inspire
and Equip Every Child with Every
Opportunity Every Day”
Sonja
S. Harris
Computer
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.
Elizabeth
1 Like