It seems like it should be simple but I cannot get my code to count from the list/table. The watcher seems to show I did something wrong. I attached what a watcher should like from an app we did and how my watcher will not show my list. Thanks in advance for any help.
list help.pdf (85.0 KB)
if your issue is in the first screen snippet your encasing foods
as a 2d array rather than just expecting it to be a 1d array additionally you are also comparing a statement in a for loop that will never complete that will probably crash your program since you don’t have a manual break statement or a comparison statement to stop that loop. On top of that you also have a poor comparison statement looking for if the food literally matches fries vs if the dish name includes fries
those are the main pressing issues so i’ll refactor the code for you
var fries = 0;
var foods = getColumn("fav_foods", "food");
onEvent("results", "click", function () {
for (var i = 0; i < foods.length; i++) {
var food = foods[i];
if (food.toLowerCase().includes("fries")) {
fries++;
}
}
console.log("The amount of dishes containing fries were: " + fries)
})
something like this should probably suit your needs better hope this helps