I'm a newbie and trying to figure out something in Javascript that should be simple. I have 2 functions let's say
function play1(){
Promise.resolve()
.then(() => put('A', 1000))
.then(() => put('B', 1000))
}
function play2(){
Promise.resolve()
.then(() => put('C'), 1000)
.then(() => put('D'), 1000)
}
I need a third function so that it executes sequentially A, B, C, D What I've tried so far with no luck:
function playAllSequentially(){
Promise.resolve()
.then(() => play1())
.then(() => play2())
}
but this doesn't get the job done, of course I could do
Promise.resolve()
.then(() => put('A', 1000))
.then(() => put('B', 1000))
.then(() => put('C', 1000))
.then(() => put('D', 1000))
but that is not the idea
in case it matters the content of put() is
function put(text, duration){
$('#txtRemarks').text(text);
delay(duration);
}
Thanks in advance