Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit f708f41

Browse files
fixed index initialize
1 parent d7c50e6 commit f708f41

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

‎homework-classes/App.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class App {
3030
document.getElementById('dropdown-select').addEventListener('change', event => {
3131
const selectedRepo = event.target.value;
3232
const selectedData = this.repos.filter(repoData => repoData.name === selectedRepo)[0];
33-
this.fetchContributorsAndRender(selectedRepo);
33+
const index = this.repos.indexOf(selectedData);
34+
this.fetchContributorsAndRender(index);
3435
});
3536
}
3637

@@ -54,7 +55,7 @@ class App {
5455
const repo = this.repos[index];
5556
const contributors = await repo.fetchContributors();
5657

57-
const container = document.getElementById('container');
58+
const container = document.getElementById('contributors');
5859
App.clearContainer(container);
5960

6061
const leftDiv = Util.createAndAppend('div', container);

‎homework-classes/Contributor.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ class Contributor {
1515
// TODO: replace the next line with your code.
1616
const contributorsDiv = Util.createAndAppend('div', root, { id: 'contributors' });
1717
for (let contributor of listOfContributors) {
18-
Util.createAndAppend('img', contributors, { src: contributor.avatar_url, class: 'contri' });
19-
Util.createAndAppend('div', contributors, { text: contributor.login, class: 'contri' });
18+
Util.createAndAppend('img', contributors, {
19+
src: this.contributor.avatar_url,
20+
class: 'contri',
21+
});
22+
Util.createAndAppend('div', contributors, { text: this.contributor.login, class: 'contri' });
2023
Util.createAndAppend('div', contributors, {
21-
text: contributor.contributions,
24+
text: this.contributor.contributions,
2225
class: 'contri',
2326
});
2427
}

0 commit comments

Comments
 (0)