-
Notifications
You must be signed in to change notification settings - Fork 19
Yuhong Week1 Assignment #18
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
jl105
wants to merge
8
commits into
frontend-application-development-uw22:main
Choose a base branch
from
jl105:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7a7ce95
Yuhong Week 1 Assignment
jl105 7010a63
Merge branch 'main' of https://github.com/jl105/week1-assignment
jl105 0bf13ef
Fix test errors
jl105 3d2771f
Yuhong Week1 Assignment
jl105 7a7d08d
Update .eslintrc.json
jl105 69ad307
Yuhong Week1 Assignment
jl105 747c9d9
Update .eslintrc.json
jl105 0497c20
Update Timer.js
jl105 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,8 @@ | |
"env": { | ||
"node": true, | ||
"jest": true | ||
} | ||
}, | ||
"rules": { | ||
"linebreak-style": ["error", "unix"] | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
// Import HTMLElement here | ||
import HTMLElement from './HTMLElement'; | ||
|
||
// Define class here | ||
class DivElement extends HTMLElement { | ||
constructor(content) { | ||
super('div', content); | ||
this.content = content; | ||
} | ||
|
||
render() { | ||
return `<div>${this.content}</div>`; | ||
} | ||
} | ||
|
||
// Export class here | ||
export default DivElement; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
// 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
import people from './people.json'; | ||
|
||
people.forEach(function (person) { | ||
people.forEach((person) => { | ||
const names = person.name.split(' '); | ||
const firstName = names[0]; | ||
const lastName = names[1]; | ||
const email = person.email; | ||
const phone = person.phone; | ||
const [firstName, lastName] = names; | ||
const { email, phone } = person; | ||
|
||
console.log('First name: ' + firstName + '\nLast name: ' + lastName + '\nEmail: ' + email + '\nPhone number: ' + phone + '\n'); | ||
console.log(`First name: ${firstName} \nLast name: ${lastName} \nEmail: ${email}\nPhone number: ${phone}\n`); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
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); | ||
} | ||
start() { | ||
const timerInterval = setInterval(() => { | ||
if (this.seconds === 0) { | ||
clearInterval(timerInterval); | ||
} | ||
|
||
console.log(instance.seconds); | ||
instance.seconds -= 1; | ||
}, 1000); | ||
}; | ||
console.log(this.seconds); | ||
this.seconds -= 1; | ||
}, 1000); | ||
} | ||
} | ||
|
||
export default Timer; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Note that this line here is optional, since the
HTMLElement
constructor takes care of assigning content to the object.