Return statement gets executed earlier than the piece of code in protractor
public newcc(newc:string):boolean
{
var Outcome:boolean=false;
this.Cc.getText().then(function (text){
var Name=text.toString();
var str_array = Name.split(',');
console.log("Cce : "+Name);
for(var i:number=0;i<str_array.length;i++) {
// if the name is found then make the outcome true and break
if(str_array[i]==cc) {
console.log(str_array[i] +" is equal to "+ClinicName);
Outcome=true;
console.log("Inside Outcome " +Outcome);
break;
} else {
console.log(str_array[i] +" is not equal to "+Cc);
}
}
});
return Outcome;
// the return always exectued earlier than above `this.ClinicList.getText()`
}
Because of this always the method returns false even if it is true.