Hello there, I have a question about the best way ...
# ask-questions
c
Hello there, I have a question about the best way to execute the variation. To check if the feature is on and the current variation the best way to execute the code is this way?
Copy code
gb.loadFeatures().then(function() {
  if (gb.isOn("widget") && variationId == 1) {
    document.getElementById("gb_with-widget").style.display = 'flex'
    document.getElementById("gb_no-widget").remove()
  }
}
f
is “widget” a boolean feature?
Assuming it is, that ‘isOn’ will be true or false depending on if its the control (off) or the second variation (on)
(by default, you can adjust this in the UI)
c
Hmm, I debugged in console that the 2 variations is executing the code inside the
isOn
, if the id variation is 0 (default/control variation) doesn't should execute the code?