I have two function which have different process time, lets say one() takes 1 second, two() takes 0.3 second. I trying to run function one() runs first and then do function two() using promise. in my code i set two() as resolved, but actually its runs function two() before one() finished.
sorry my english not that good, i hope you understand my context here
main();
function main() {
let promise = new Promise(function(resolved) {
one();
resolved();
});
promise.then(two());
}
function one() {
setTimeout(() => {
console.log("ONE");
}, 1000);
}
function two() {
setTimeout(() => {
console.log("TWO");
}, 300);
}