I'm studying the promises. What interests me is to understand how to link two functions in a promise.
I'll explain. I want that on completion of one function (if successful) the second function is executed.
For example, I have these two functions very simple; at the end of the sum() function, if successful, the print() function will be executed.
In the case of time-consuming functions, is it worth adding a setTimeout?
Can anyone kindly help me?
function sum(){
  let array = [3, 5, 4, 8];
  let sum = 0;
  array.forEach(item => {
    sum += item;
  });
  console.log(sum);
}
function print(){
  console.log("This function is printed after the sum function if the latter was successful")
 }
 
sum();
print(); 
    