-
Notifications
You must be signed in to change notification settings - Fork 16
week1 hw #16
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
base: master
Are you sure you want to change the base?
week1 hw #16
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,13 @@ | ||
| // Import HTMLElement here | ||
| import HTMLElement from './HTMLElement'; | ||
|
|
||
| // Define class here | ||
| class DivElement extends HTMLElement { | ||
| constructor(content) { | ||
| super('div', content); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
| } | ||
| } | ||
|
|
||
|
|
||
| // Export class here | ||
| export default DivElement; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,13 @@ | ||
| // Define class here | ||
| class HTMLElement { | ||
| constructor(tag, content) { | ||
| this.tag = tag; | ||
| this.content = content; | ||
| } | ||
|
|
||
| render() { | ||
| return `<${this.tag}>${this.content}</${this.tag}>`; | ||
| } | ||
| } | ||
| // Export class here | ||
| export default {}; | ||
| export default HTMLElement; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "folders": [ | ||
| { | ||
| "path": "/Users/i534961/Documents/JS" | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,11 +1,6 @@ | ||||||
| import people from './people.json'; | ||||||
|
|
||||||
| people.forEach(function (person) { | ||||||
| const names = person.name.split(' '); | ||||||
| const firstName = names[0]; | ||||||
| const lastName = names[1]; | ||||||
| const email = person.email; | ||||||
| const phone = person.phone; | ||||||
|
|
||||||
| console.log('First name: ' + firstName + '\nLast name: ' + lastName + '\nEmail: ' + email + '\nPhone number: ' + phone + '\n'); | ||||||
| people.forEach((element) => { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| const [firstName, lastName] = element.name.split(' '); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| console.log(`First name: ${firstName}\nLast name: ${lastName}\nEmail: ${element.email}\nPhone number: ${element.phone}\n`); | ||||||
| }); | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,17 @@ | ||
| function Timer(seconds) { | ||
| this.seconds = seconds; | ||
| } | ||
| class Timer { | ||
| constructor(seconds) { | ||
| this.seconds = seconds; | ||
| } | ||
|
|
||
| Timer.prototype.start = function () { | ||
| var instance = this; | ||
| var timerInterval = setInterval(function () { | ||
| if (instance.seconds === 0) { | ||
| clearInterval(timerInterval); | ||
| } | ||
|
|
||
| console.log(instance.seconds); | ||
| instance.seconds -= 1; | ||
| }, 1000); | ||
| }; | ||
| start() { | ||
| const timerInterval = setInterval(() => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great work! |
||
| if (this.seconds === 0) { | ||
| clearInterval(timerInterval); | ||
| } | ||
|
|
||
| this.seconds -= 1; | ||
| }, 1000); | ||
| } | ||
| } | ||
| export default Timer; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄