-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
  • 25,247
  • 27
  • 110
  • 174
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
  • 23,737
  • 12
  • 48
  • 51
Daniel A. White
  • 181,601
  • 45
  • 354
  • 430