Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c351f9d

Browse files
committed
Rename createAndAppend to createAppend
1 parent 7f2833b commit c351f9d

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

Week1/MAKEME.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ _**Do not change or delete any files outside of the `homework` folder!**_
129129

130130
2. Open `index.js`. This file contains a starter set of code for you to expand. It contains the following three functions:
131131

132-
| Function | Description |
133-
| ----------------- | ------------------------------------------------------------------------------------------------------------ |
134-
| `fetchJSON` | Uses `XMLHttpRequest` to fetch JSON data from an API end point. This function uses an asynchronous callback. |
135-
| `createAndAppend` | A utility function for easily creating and appending HTML elements. |
136-
| `main` | Contains the start-up code for the application. |
132+
| Function | Description |
133+
| -------------- | ------------------------------------------------------------------------------------------------------------ |
134+
| `fetchJSON` | Uses `XMLHttpRequest` to fetch JSON data from an API end point. This function uses an asynchronous callback. |
135+
| `createAppend` | A utility function for easily creating and appending HTML elements. |
136+
| `main` | Contains the start-up code for the application. |
137137

138138
`index.js` also contains a constant with the URL for the HYF repositories as listed in section 2.2.1:
139139

@@ -175,7 +175,7 @@ It should include the following components:
175175

176176
**`index.js`**
177177

178-
- Add new functions and modify function `main()` as you see fit. It is not likely that you will need to modify `fetchJSON()` and `createAndAppend()`.
178+
- Add new functions and modify function `main()` as you see fit. It is not likely that you will need to modify `fetchJSON()` and `createAppend()`.
179179

180180
**`style.css`**
181181

homework-classes/App.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ class App {
1818
// 2. Make an initial XMLHttpRequest using Util.fetchJSON() to populate your <select> element
1919

2020
const root = document.getElementById('root');
21-
const header = Util.createAndAppend('header', root, { class: 'header' });
22-
this.mainContainer = Util.createAndAppend('div', root, { id: 'container' });
21+
const header = Util.createAppend('header', root, { class: 'header' });
22+
this.mainContainer = Util.createAppend('div', root, { id: 'container' });
2323

2424
try {
2525
const repos = await Util.fetchJSON(url);
@@ -50,10 +50,10 @@ class App {
5050
this.clearContainer();
5151
const contributors = await repo.fetchContributors();
5252

53-
const repoContainer = Util.createAndAppend('div', this.mainContainer);
54-
const contributorContainer = Util.createAndAppend('div', this.mainContainer);
53+
const repoContainer = Util.createAppend('div', this.mainContainer);
54+
const contributorContainer = Util.createAppend('div', this.mainContainer);
5555

56-
const contributorList = Util.createAndAppend('ul', contributorContainer);
56+
const contributorList = Util.createAppend('ul', contributorContainer);
5757

5858
repo.render(repoContainer);
5959

homework-classes/Contributor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ class Contributor {
1414
*/
1515
render(container) {
1616
// TODO: replace the next line with your code.
17-
Util.createAndAppend('pre', container, { text: JSON.stringify(this.contributor, null, 2) });
17+
Util.createAppend('pre', container, { text: JSON.stringify(this.contributor, null, 2) });
1818
}
1919
}

homework-classes/Repository.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Repository {
1414
*/
1515
render(container) {
1616
// TODO: replace the next line with your code.
17-
Util.createAndAppend('pre', container, { text: JSON.stringify(this.repository, null, 2) });
17+
Util.createAppend('pre', container, { text: JSON.stringify(this.repository, null, 2) });
1818
}
1919

2020
/**

homework-classes/Util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// eslint-disable-next-line no-unused-vars
44
class Util {
5-
static createAndAppend(name, parent, options = {}) {
5+
static createAppend(name, parent, options = {}) {
66
const elem = document.createElement(name);
77
parent.appendChild(elem);
88
Object.keys(options).forEach(key => {

homework/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
xhr.send();
1717
}
1818

19-
function createAndAppend(name, parent, options = {}) {
19+
function createAppend(name, parent, options = {}) {
2020
const elem = document.createElement(name);
2121
parent.appendChild(elem);
2222
Object.keys(options).forEach(key => {
@@ -34,10 +34,10 @@
3434
fetchJSON(url, (err, repositories) => {
3535
const root = document.getElementById('root');
3636
if (err) {
37-
createAndAppend('div', root, { text: err.message, class: 'alert-error' });
37+
createAppend('div', root, { text: err.message, class: 'alert-error' });
3838
return;
3939
}
40-
createAndAppend('pre', root, { text: JSON.stringify(repositories, null, 2) });
40+
createAppend('pre', root, { text: JSON.stringify(repositories, null, 2) });
4141
});
4242
}
4343

0 commit comments

Comments
 (0)