Problems Unit 5 Hackathon High Score Sample App

Hi everyone. I would like to discuss this sample because I really think it is not the best one to be used as a guide and/or to share with the students.

The idea of the program is to look for the minimum and maximum values on different categories in order to display the corresponding cereal brand on the user interface.

The problem is that, for some categories, there are several cereal brands meeting the conditions. Ex: both Cheerios and Special K have the most proteins with a value of 6 grams. Another example: Cinnamon Toast Crunch, Cracklin’ Oat Bran, and Great Grains Pecan all have the maximum fat value with 3 grams. There are also similar cases for the minimum values.

When traversing the category list, we get the first of the maximum or minimum values and only display one brand name on the screen. This is wrong.

I modified the sample code by adding an extra loop. I would like to know what you think. I also would like to know if there is a better solution. This is what I did with the findMost function. I used a similar code for the findLeast function.

New findMost function:

function findMost() {
var input = getText(“mostDropdown”);
var category = getColumn(“Cereal Nutrition”, input);
var filteredMaxNames = ;
var max = 0;
var mostName;
for(var i = 0; i < category.length; i++){
if(category[i] > max) {
max = category[i];
for (var j = 0; j < category.length; j++) {
if (max == category [j] ) {
mostName = names[j];
setText(“mostOutput”, ((“The cereal/s with the most " + input) + " is/are “) + filteredMaxNames.join(”\n”));


A few more things: when remixing the app you need to import the Cereal Nutrition Table again, but you also have to change the names of the categories in the design tab, since they are different from the ones used in the sample.

Also, you will have to be especially careful with the protein column named: Grams of Protein. The column name has an extra space between the words “of” and “Protein”. You either need to edit the name in the table or add an extra space in the name in the dropdown menu. If not, you will see an error message in the console.

1 Like

Thanks for pointing this out. I will pass on this info to the staff. I like your solution that finds a list of all cereals that fit the criteria.

In the future, if you find any other mistakes please let know.

1 Like

Hi there. Sorry, but there is something else.

When the students select a category from the dropdown menu and, after that, they select Pick a Category, they get an error message. The message says: "You tried to get a column called “Pick a Category” from a table called “Cereal Nutrition”, but that column doesn’t exist. "

To solve this other issue, I added another if statement. See the screenshot.

Thank you,