выполнить одну функцию после завершения другой
Как добиться выполнения данного кода последовательно? Я попробовала несколько вариантов, ничего не работает, неизменно в консоль сначала выводится 'second', потом 'first'
const command = async () => {
setTimeout(() => console.log('first'), 800)
}
const start = async () => {
await command();
console.log('second');
}
start()
const command = async () => {
setTimeout(() => console.log('first'), 800)
}
const start = async () => {
command().then(() => {
console.log('second');
})
}
start()
const command = async () => {
setTimeout(() => console.log('first'), 800)
}
const start = async () => {
new Promise((res, rej) => {
command()
res()
}).then(() => console.log('second'))
}
start()