• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

128
Views
Comparion of 2 equal strings returns false

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:

enter image description here

What is the problem here? I have tried making the exact same comparison in an online playground where it returned true.

about 3 years ago · Santiago Trujillo
1 answers
Answer question

0

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

about 3 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error