Rahul Singh
Rahul Singh

Reputation: 1632

Calling second function in first function

I have particular function named profilefrm() in which I am checking conditions returning true or false, I have created another function checkcontacts(). I have called this function in first one. I have successfully returning true or false from second one. I have flow is

function profilefrm(){
if condition1{
// on false 
returning false;
}
checkcontacts();
}

function checkcontacts(){
if condition1{
// on false 
returning false;
}
return true;
}

But issue is on false condition in second function it is taken as true in first one. and refreshing page accordingly.

Upvotes: 0

Views: 346

Answers (2)

shotasenga
shotasenga

Reputation: 979

function's return value should specify. function do no return if not specify.

firtst function change to below.

function profilefrm(){
    if condition1{
        // on false 
        returning false;
    }
    return checkcontacts();
}

Upvotes: 0

Darin Dimitrov
Darin Dimitrov

Reputation: 1038720

You could return the result of the checkcontacts function:

function profilefrm() {
    if (condition1) {
        // on false 
        return false;
    }

    return checkcontacts();
}

Upvotes: 1

Related Questions