I am comparing the value of a checkbox with the values of strings in an array. I am printing out all the comparisons in like so:
checkSkillLevel(index: number, level: string){
console.log(this.currentAdditionalInfo.skills[index].level + "=" + level + " ?");
console.log("boolean: " + this.currentAdditionalInfo.skills[index].level == level);
}
In one of the comparisons, the value of the checkbox is "low" and the value in the array is also "low". I have also tried comparing them with ===
. In both cases, it returns false, as seen in my log:
What is the problem here? I have tried making the exact same comparison in an online playground where it returned true
.
Please make sure that both string in same case.
Also please see below code
console.log("Boolean:" + "low"=="low") --- o/p false
console.log("low"=="low") ---- o/p true