mardi 20 décembre 2016

How can I correctly check if a string does NOT contain a specific word in javascript?

I am currently trying to figure out how to solve the above named problem. Specifically I want to check if the string does NOT contain the word "stream" both in capital and lowercase letters. Here's my code so far:

`if (((gewaesser_name1.includes("Stream") == "false") ||
(gewaesser_name1.includes("stream") == "false")) &&
((gewaesser_name2.includes("Stream") == "false") ||
(gewaesser_name2.includes("stream") == "false")))
{var a= "..."}`

The code does obviously not work as the results are not what I expect them to be. I also tried to use the indexOf method before using the following syntax variations:

`gewaesser_name2.indexOf("stream") == -1
 gewaesser_name2.indexOf("stream") < 0`

None of these variations seem to work for me. Could anyone please give me a hint what's the problem here? I used the indexOf method before many times but always when I wanted to check if a string did contain a specific word, not the other way round.

Looking forward to your answers, thanks in advance.

Greetings, niccober

Aucun commentaire:

Enregistrer un commentaire