Skip to content

Conversation

@Dmytro-Doronin
Copy link

No description provided.

@remarcmij remarcmij self-assigned this Oct 6, 2025
Copy link

@remarcmij remarcmij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI @Dmytro-Doronin, good work here. Only ex4 needs a tweak before I can approve. See below.

})
.catch((err) => {
console.log(err);
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

} else {
reject (new Error ( `Expected a double digit number but got ${number}`))
}
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Now here is a challenge. When you run the code you get this output:

This is a double digit number!
This is a double digit number!
Expected a double digit number but got 9
Expected a double digit number but got 100

But looking at the code you might expect:

Expected a double digit number but got 9
This is a double digit number!
This is a double digit number!
Expected a double digit number but got 100

Why is it that you get the former and not the latter? 🤯

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Because of tests don't allow me putting number here -> This is a double digit number!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your code was fine. The question was why the order of the output was not as initially expected. This has to do with the order of microtasks creation.

// (resolved or rejected) only once. Any subsequent calls to resolve/reject
// are ignored by the specification. Therefore, even if we keep “rolling”
// the die and logging values after a reject, the promise won’t complete
// a second time—there’s no “double” result. In the code above, this is

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The em-dash here gives you away as having used AI to answer this question. I'm okay with that so long as you actually understand what it says.

/*
Promise.all rejects early, but it does not stop or cancel the other
promises, therefore unfinished dice keep rolling and logging.
*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run your code, it only mentions Die 1. We have 5 dice in the array. What's missing to incorporate all 5?

Current sample output:

14:32:55.146 Die 1 scheduled for 3 rolls...
14:32:55.151 Die 1 is now: QUEEN
14:32:55.151 Die 1 scheduled for 8 rolls...
14:32:55.151 Die 1 is now: TEN
14:32:55.151 Die 1 scheduled for 4 rolls...
14:32:55.151 Die 1 is now: NINE
14:32:55.151 Die 1 scheduled for 6 rolls...
14:32:55.151 Die 1 is now: ACE
14:32:55.151 Die 1 scheduled for 3 rolls...
14:32:55.151 Die 1 is now: NINE
14:32:55.648 Die 1 is now: NINE
14:32:55.649 Die 1 is now: KING
14:32:55.651 Die 1 is now: NINE
14:32:55.651 Die 1 is now: TEN
14:32:55.654 Die 1 is now: KING
14:32:56.145 Die 1 is now: JACK
14:32:56.146 Die 1 settles on JACK in 3 rolls.
14:32:56.146 Die 1 is now: NINE
14:32:56.149 Die 1 is now: KING
14:32:56.150 Die 1 is now: ACE
14:32:56.157 Die 1 is now: ACE
14:32:56.157 Die 1 settles on ACE in 3 rolls.
14:32:56.642 Die 1 is now: TEN
14:32:56.646 Die 1 is now: ACE
14:32:56.649 Die 1 is now: KING
14:32:56.649 Die 1 settles on KING in 4 rolls.
14:32:57.138 Die 1 is now: ACE
14:32:57.144 Die 1 is now: TEN
14:32:57.634 Die 1 is now: KING
14:32:57.635 Die 1 settles on KING in 6 rolls.
14:32:57.643 Die 1 is now: NINE
14:32:58.142 Die 1 is now: KING
14:32:58.142 Die 1 continues rolling on the floor...
Rejected! Die 1 rolled off the table.

14:32:58.640 Die 1 is now: ACE
14:32:58.640 Die 1 settles on ACE in 8 rolls.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for your feedback! I've already fixed ex 4! Plese, check it again :)

// TODO Replace this comment by your explanation that was asked for in the assignment description.
/*
Promise.all rejects early, but it does not stop or cancel the other
promises, therefore unfinished dice keep rolling and logging.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

.then((value) => {
results.push(value);
return rollDie(5);
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link

@remarcmij remarcmij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. I can now approve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants