How can I prevent a function to start before the previous function has been completed? See example below:
In this example I have the 1st funtiction which takes around 10 seconds to complete, then the 2nd function takes around 3 seconds, and then there is an alert to help me understand if two lists included in those function are empty or not. As it current stands the alert shows 0 0 almost immediately (and in the meantime the functions continue to work).
What I would like to achieve is as follows:
- 1st function completed, then
- 2nd function completed, then
- Alert shows
Could you please help me understand how can I reach this result? Thank you!