So basically I have a web application that uses promise. Below is my code:

```
for(var key in data){               
    var promise = getDataFNLN(idOfReviewee);
    promise.then(function(returnedFnLn){
        count = count + +1;
        AllReviewee[count] = returnedFnLn;

        console.log("firsst");
        return getDataFNLN(idOfReviewer[count]);
    }).then(function(returnedFnLn){
        count1 = count1 + +1;
        AllReviewer[count1] = returnedFnLn;

        console.log("second");
    })
}

function getDataFNLN(idRev){
    return new Promise (function(resolve,reject){
        getDataToUsers = firebase.database().ref("users").child(idRev);
        getDataToUsers.once("value",function(snap){ 
            var fnLn =snap.val();
            var first = fnLn.firstname;
            var second = fnLn.lastname;
            forPromiseFnLn = first.concat(" ",second);

            resolve(forPromiseFnLn);    
        });
    });
}

```

Assuming that the data variable in the for loop has 4 data, so it will loop four times. And through promise the output of the console must be: 

> 
> first  
> 
>  second  
> 
>  first  
> 
>  second  
> 
>  first  
> 
>  Second  
> 
>  First  
> 
>  Second
> 
> 
> 

but instead it outputs like this:

> 
> first  
> 
>  first  
> 
>  first  
> 
>  first  
> 
>  Second  
> 
>  Second  
> 
>  Second  
> 
>  Second
> 
> 
>