If as function

Asked

Viewed 35 times

-1

How to define an "IF" run according to text of a "var"? Ex:

var Ativar = {
 ativo: 'sim'
};

I intend to use the "yes" for "IF" to validate and execute. Does anyone know how to?

Pardon my explanation. I hope you understand my claim. Thank you.

1 answer

0


I don’t know if that’s what you meant, but try it this way:

if(ativar.ativo == 'sim'){
    //função
}

Don’t forget to always declare variables with the first lowercase letter ("var activate = {}")

  • Exactly that, rust fell from my eyes when I saw the capital A there. Thank you very much.

  • No problem. Managed to achieve the result you needed?

  • Sorry for the delay in answering. Due to the Stack policy, I could not answer before. Yes the problem was fixed. It was just the error in var. Thank you.

  • All right, I’m glad.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.