comparing two strings in javascript code example
Example 1: compare strings js
const s1 = 'learn';
const s2 = 'today';
console.log(s1 === 'learn');
console.log(s1 === s2);
Example 2: javascript not equal
0 !== "0"
0 !== 0
Example 3: how to compare two strings in javascript if condition
var string1 = "Hello World";
var string2 = "Hello world.";
if (string1 === string2) {
console.log("Matching strings!");
}
else {
console.log("Strings do not match");
}
Example 4: javascript compare strings
console.log(NaN===NaN);