How do I hold execution in loop for a value condition

Hi,
i want to hold a function for a condition, then to call another function.

var level = 1;
    while (level<3) {

        if (score<5) {

            this.level_1();

        }
        if (score>5) {

            this.level_2();

        }
        level++;
    }
this code is executed at a time, I actually want to make level one by one for a condition. How can I do that. Please help..!

I don’t understand what you want to do.

As @slackmoehrle pointed out, what you’re asking for isn’t clear, but at a guess, it’s not something related to Cocos2d-x, but more so programming knowledge, so this may help:

https://www.learncpp.com/

you need event loop, make infinite loop run it untill event occours but i suggest to use some library or example code