Pedro098 0 Posted January 30, 2019 Report Share Posted January 30, 2019 Boas, Estou a fazer um projeto em que pretendo criar uma função em javascript que verifique alterações numa variável. Por exemplo: <a id="exp">0</a> function myfunc1(){ exp += 1; } function myfunc2(){ if(exemple >= exemple2){ exp += 1; } Onde myfunc1() representa uma função onclick() e myfunc2() também. O que eu pretendo é criar uma função que verifique o valor da variável exp. Por exemplo: function checkexp(){ if(exp >= 5){ lvl += 1; } } Agradeço sugestões para resolver esta situação e qual a melhor maneira de o fazer. Obrigado. Link to post Share on other sites
Zex 8 Posted June 15, 2019 Report Share Posted June 15, 2019 O mais simples é invocar a função checkexp() no final das funções myfunc1() e myfunc2() Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now