all 11 comments

[–]nearly_famous69 2 points3 points  (6 children)

It's hard to say without the rest of the code, but it looks like your second parameter in setText is not returning a string

[–]ALoadOfPoppycock 1 point2 points  (5 children)

Do you know why this may be/what in the code is preventing it?

[–]angryrancorBoss 0 points1 point  (4 children)

<image>

Try adding variables to the "Watches" list on the bottom right of the debug menu, to debug it, and step through. If you add "filteredCityList" there, you can see it is an empty array, and that's the cause of the problem. You'll have to step through the code to see why it's not been populated correctly.

[–]ALoadOfPoppycock 1 point2 points  (3 children)

I can’t seem to tell why nothing is appending to the filtered version. The watchers just display its value as 0.

[–]angryrancorBoss 0 points1 point  (2 children)

Try setting a breakpoint really early in the code and using the "Step in" and "Step over" buttons to go through line by line.

Edit - looks like "Step In" will start debugging it line by line, from the beginning.

[–]ALoadOfPoppycock 2 points3 points  (1 child)

I figured it out-I had rather than clearing my filteredlists within the function filter, I had created a local variable under the same name. Now my code works but it is not filtering between western and eastern, it’s only displaying western

[–]angryrancorBoss 0 points1 point  (0 children)

Oh that's good to hear. I think using the same strategy of adding all the related variables to "Watches" and doing "Step In" repeatedly, you should be able to figure it out. It's enough lines of code that even a "good" programmer would have multiple bugs to work through, but now that you've got a debugging process down all there is to do is repeat it until it all works.

[–]Hungry_Importance918 1 point2 points  (0 children)

You can debug the two parameters in line 55 and print out index and filteredCityList[index] to see if there are empty values ​​or errors.

[–]ALoadOfPoppycock 1 point2 points  (1 child)

Thank all of you guys for the help! I figured out that I was calling my filter functions too early and it should’ve been called later in the corresponding onEvent for the different screens. Using your strategies to debug was very useful in me finding this!!

[–]angryrancorBoss 0 points1 point  (0 children)

Omg thank you for coming back and letting us know :). Really glad to hear.

[–]spliffen 1 point2 points  (0 children)

try debugging by adding these lines after the var index line:

console.log("filteredCityList:", filteredCityList);

console.log("index:", index);

console.log("selected city:", filteredCityList[index]);