Problem with break


#1

Hi everybody,
i need help i’m noob on imp and i want to break a function with if condition but when i put a break inside the if ide says that break has to be in loop block, i dont know why ,if some one could help me


#2

Like the error says, “break” is used for prematurely terminating a loop. If your goal is to stop executing a function early, you probably want “return” instead.

For example:

`
function foo(bar) {
    if (bar == true) {
        return;
    }

    server.log("if you can read this, bar is false!");
}
`

#3

ok,thanks a lot gino