Skip to content

Oleksandr Starshynov w2 UsingAPIs #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

aleksandrstarshynov
Copy link

No description provided.

const dice = [1, 2, 3, 4, 5];
// TODO complete this function; use Promise.race() and rollDie()
rollDie(1); // TODO placeholder: modify as appropriate
const promises = dice.map(() => rollDie());

Choose a reason for hiding this comment

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

Though the output of this code is close to what we want but something is missing:
The dice array is [1, 2, 3, 4, 5], but the values in this array are not used in the map() function.
The map() function calls rollDie() five times (once for each element in the array), but it does not pass any arguments to rollDie().

Therefore, line 10 was supposed to be like const promises = dice.map((dice) => rollDie(dice));.

Can you update this, so that our output in the terminal looks as follows:

09:10:37.116 Die 1 scheduled for 4 rolls...
09:10:37.128 Die 1 is now: NINE
09:10:37.129 Die 2 scheduled for 4 rolls...
09:10:37.129 Die 2 is now: TEN
09:10:37.129 Die 3 scheduled for 6 rolls...
09:10:37.129 Die 3 is now: NINE
09:10:37.130 Die 4 scheduled for 6 rolls...
09:10:37.130 Die 4 is now: NINE
...

@@ -11,21 +11,20 @@ async function getData(url) {
function renderLaureate({ knownName, birth, death }) {

Choose a reason for hiding this comment

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

A couple of things are missing:

@@ -11,21 +11,20 @@ async function getData(url) {
function renderLaureate({ knownName, birth, death }) {
console.log(`\nName: ${knownName.en}`);
console.log(`Birth: ${birth.date}, ${birth.place.locationString}`);
Copy link

@ddoyediran ddoyediran Apr 20, 2025

Choose a reason for hiding this comment

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

We are supposed to log the en property of this object birth.place.locationString.en. So that line 13 looks like:

console.log(`Birth: ${birth.date}, ${birth.place.locationString.en}`);

function renderLaureates(laureates) {
laureates.forEach(renderLaureate);
if (death) {
console.log(`Death: ${death.date}, ${death.place.locationString}`);
Copy link

@ddoyediran ddoyediran Apr 20, 2025

Choose a reason for hiding this comment

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

Same as line 13:

console.log(`Birth: ${birth.date}, ${birth.place.locationString.en}`);

laureates.forEach(renderLaureate);
if (death) {
console.log(`Death: ${death.date}, ${death.place.locationString}`);
}
}

Choose a reason for hiding this comment

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

For this exercise to work, we supposed to have additional function renderLaureates that uses forEach method on the laureates array.
The forEach method iterates over each element in the array and applies a callback function to it as follows:

function renderLaureates(laureates) {
  laureates.forEach(renderLaureate);
}

Choose a reason for hiding this comment

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

This is working as expected.

addTableRow(table, 'Birth', `${birth.date}, ${birth.place.locationString}`);
addTableRow(table, 'Death', `${death.date}, ${death.place.locationString}`);

const birthInfo = birth ? `${birth.date}, ${birth.place.locationString}` : 'Unknown';
Copy link

@ddoyediran ddoyediran Apr 20, 2025

Choose a reason for hiding this comment

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

Same as exercise 5, we need to add en to this line 30 (${birth.place.locationString.en}) and line 33.

Can you update line 30 and 33 to look like this?

Line 30:

const birthInfo = birth ? `${birth.date}, ${birth.place.locationString.en}` : 'Unknown';

Line 33:

const deathInfo = death ? `${death.date}, ${death.place.locationString.en}` : 'Unknown';

Choose a reason for hiding this comment

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

@aleksandrstarshynov This feedback wasn't implemented - exercise 6 is not working as expected.


### 3-UsingAPIs - Week2

| Exercise | Passed | Failed | ESLint |

Choose a reason for hiding this comment

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

@aleksandrstarshynov Great job. To approve this, there are a couple of things we need to update. You can find my comments/ feedbacks for each exercise. Let me know if you have any questions.

@aleksandrstarshynov
Copy link
Author

@ddoyediran Thank you for your support.

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