"not in" for arrays in Javascript
MattyB10 (0)

Python is my main language, but I am trying to learn Javascript. In python, you could say "variable not in list". I don;t know how to do this in JS and I can;t find it anywhere. If you could help that would be great. I have posted a pic below, the blue circle is where the problem lies. Also, courses is a list, and z is an input.

You are viewing a single comment. View All
mat1 (2513)
if (!list.includes(variable))

.includes checks if the list does include variable, and the exclamation point makes it check if it's not true.
Please mark this comment as the answer if it answered your question. Thanks!