Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Same string comparison never returns true

If I assign:

Content = 'On' 

and check

if ('On' === Content) {} // it returns true

But when I get a value dynamically returned from Content as On. I could see ‘On’ in console.log

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

if ('On' === Content) {}
// this never returns true, they are same case(case sensitiveness) as well.

May I know what could be the reason?

>Solution :

Try to trim the dynamic content variable like the below and then try:

if ('On' === Content.trim()) {}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading