0

How can you make a if statement that a prompt tags value is not any value of a array?

So a example will be alerting(Using alertia which makes cool alerts) if the prompt value is not a array. So my code has a 32 amount of values in my array. Then I wrote a if statement. if (askPrompt == keywords[0]) { //alert than it isn’t a good variable name. } But it would take forever to write keywords[0] to keywords[31] for array indices.

23rd May 2020, 6:53 PM
Sali65
Sali65 - avatar
2 ответов
+ 3
if (!keywords.includes(varName)) { alert("Not a valid variable name") }
23rd May 2020, 7:04 PM
rodwynnejones
rodwynnejones - avatar
23rd May 2020, 6:54 PM
Sali65
Sali65 - avatar