Same string comparison never returns true

Advertisements

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

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()) {}

Leave a ReplyCancel reply