+ 1

How to make a NOT includes in js

I mean its just an includes in js but reverse the true will be false and the false will be true https://code.sololearn.com/W69veGAmYT1N/?ref=app

30th Mar 2022, 1:50 PM
Domge
Domge - avatar
4 Answers
+ 2
if (!words.includes("word") { //Not exist "word" in words }
30th Mar 2022, 4:26 PM
A͢J
A͢J - avatar
+ 2
! true = > false ! false = > true ! => not opearator
30th Mar 2022, 2:10 PM
Jayakrishna 🇮🇳
+ 2
Let's say you checked it as follows ... var exists = haystack.includes( needle ); <exists> will be true when <haystack> has <needle> as one of its substring. If you want to inverse <exists> in JS log, you can simply use the unary logical NOT operator as follows, console.log ( !exists );
30th Mar 2022, 2:11 PM
Ipang
0
something like this? var someString = "just a random string"; var value = someString.includes("random") ? false : true; console.log(value); stored the inverse of includes() in another variable value OR just directly use the ternary operator where you wish to reverse the value
30th Mar 2022, 2:10 PM
Birb
Birb - avatar