Ask coding questions

← Back to all posts
1
"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.

Commentshotnewtop
1
mat1 (2260)
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!