Updated 2022-05-21 0
Viewed 8 times
0

I'm writing a function in JS that will iterate through a python list and see if any of the numbers in that list match the parameter that is the input for the function. Here's the code:

function popup(elementId)
        {
            for (i = 1; i < {{ len_days }} ; i++) {
                if (elementId === {{ days_list[i] }}) {
                    document.getElementById(elementId.toString()).innerHTML = "working"
                    var popup_element = document.getElementById(elementId);
                    popup_element.classList.toggle("show");
                }
            }
        }

In this case {{days_list}} is the python list. I'm able to select the specific index by using [0] or [1], but I want to be able to use [i] to iterate through all the items in this list. Is there a way for me to use the same i as in the JS for loop, or do I have to make it in python?

🔴 No definitive solution yet