0

I am getting values as True and False from back-end. I am trying to convert those values as real Boolean values, But I am getting always true with my approach. What would be the correct way to do this?

here is my try:

var x = Boolean("False".toLowerCase());

console.log( x ); //giving true instead of false.
Louis Barranqueiro
  • 9,390
  • 6
  • 39
  • 51
user2024080
  • 5,068
  • 12
  • 46
  • 81

2 Answers2

2

You can use this :

var str = "False";
var x = str.toLowerCase() == "false" ? false : true;
Zeus
  • 1,145
  • 11
  • 19
0

try this code.

var x = Boolean("true" == "False".toLowerCase());
Abed Alzain
  • 739
  • 4
  • 9