-4

I've read numerous examples converting from String to Boolean.

For example,

myString = (myString == "true");

But I'm unable to apply the logic to my code. Can someone help?

CommonConfig.getFeatureFlags['analytics.demo'] returns "true" (Note the "").(That's how backend returns it)

var FeatureFlag = _.extend(CommonConfig, {
    demoFeature: String == CommonConfig.getFeatureFlags['analytics.demo'], //either "true" or "false" but I want to make it to true or false
});

Question: I want to convert from String "true" to boolean. And pass true or false based upon!

Can someone help?

TechnoCorner
  • 4,591
  • 9
  • 32
  • 73

1 Answers1

0

Isn't it:

var FeatureFlag = _.extend(CommonConfig, {
    demoFeature: "true" == CommonConfig.getFeatureFlags['analytics.demo'], 
});
Sudsy
  • 919
  • 7
  • 16