-3

I found some posts related but i cant make it work.

I have a variable:

var object = {id: "4", black: false, destacado: ""};

I need to make an if that makes something if "black" is true.

Liam
  • 27,717
  • 28
  • 128
  • 190
Daijard
  • 83
  • 1
  • 1
  • 8

1 Answers1

2

Simply

if (object.black === true) {
    // do your thing
}

Using === ensures that it is true and not some other truthy value.

Racil Hilan
  • 24,690
  • 13
  • 50
  • 55
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445