U5 Hackathon List Filtering Issue

I have a student who created the app above. The issue is, the lists are not filtering correctly. Some of the schools that should be filtered into the smallSchools list are appearing else where.

I am not sure where the logic error lies since some of the schools are filtering properly and others are not.

This problem cropped up before. Enrollment is in the database as a string. You can’t compare two strings that represent numbers and have them work mathematically. They work alphabetically which is going to be different than what you expect to happen. For example “2,000” is larger than “10,000” in the world of strings.

If your class can use libraries here is one that fixes the Enrollment column. C6OYfZDdnF_5vJ5YddKsKwOLbbUt8oQ3Dj_1WahVI2A
Here is a small example of using it Code.org - App Lab.

After you change the enrollment column to be a number you can change your program to compare it to numbers and it will work.

2 Likes

I thought that was the issue, but I didn’t know of a solution.

Thank you so much for your input!