-1

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
  • 10,058
  • 6
  • 42
  • 52
user2024080
  • 1
  • 14
  • 56
  • 96

2 Answers2

2

You can use this :

var str = "False";
var x = str.toLowerCase() == "false" ? false : true;
Zeus
  • 1,235
  • 12
  • 20
0

try this code.

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