How to continue the function only after obtaining the values from another?

When calculating call the function
pr2.result = pr2.data + mailBoxFunctional(pr2,pr1);


The function uses the SetTimeout:
mailBoxFunctional function (receiver, sender) {
 var message = `${receiver.name} requested data ${sender.name}`;
alert(message);
 var getData = sender.GetData(sender);
 var message2 = `${sender.name} sent to the mailbox of the process ${receiver.name}`;
alert(message2);
 setTimeout(function (argument) {
 return getData 
 } , 5000);
}

Of course, out undefined, because the calculation occurs before obtaining a value from a function.
How to fix it?
July 2nd 19 at 13:09
1 answer
July 2nd 19 at 13:11
Solution

Find more questions by tags JavaScript