+ 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
4 odpowiedzi
+ 2
if (!words.includes("word") {
//Not exist "word" in words
}
+ 2
! true = > false
! false = > true
! => not opearator
+ 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 );
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