Skip to content

week1 ✅ #4

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 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions src/components/DivElement.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
// Import HTMLElement here
import HTMLElement from './HTMLElement';

// Define class here
// DivElement /////////////////////////////////////////////////////////////////
// An HTML <div> and its inner [content].
class DivElement extends HTMLElement {
// constructor ////////////////////////////////////////////////////////////
// Constructs DivElement with given [content].
constructor(content) {
super();
this.tag = 'div';
this.content = content;
}
}

// Export class here
export default DivElement;
21 changes: 18 additions & 3 deletions src/components/HTMLElement.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
// Define class here
// HTMLElement ////////////////////////////////////////////////////////////////
// An HTML [tag] and its inner [content].
class HTMLElement {
// constructor ////////////////////////////////////////////////////////////
// Constructs HTMLElement with given [tag] and [content].
constructor(tag, content) {
this.tag = tag;
this.content = content;
}

// Export class here
export default {};
// render /////////////////////////////////////////////////////////////////
// Returns a string with this HTMLElement's [content] wrapped in this
// HTMLElement's [tag].
render() {
return `<${this.tag}>${this.content}</${this.tag}>`;
}
}

export default HTMLElement;
16 changes: 8 additions & 8 deletions src/rolodex/rolodexPrinter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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((person) => {
const [firstName, lastName] = person.names.split(' ');
const { email, phone } = person;
console.log(`First name: ${firstName}
Last name: ${lastName}
Email: ${email}
Phone number: ${phone}
`);
});
17 changes: 9 additions & 8 deletions src/timer/Timer.js
Original file line number Diff line number Diff line change
@@ -1,16 +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) {
Timer.prototype.start = () => {
const timerInterval = setInterval(() => {
if (this.seconds === 0) {
clearInterval(timerInterval);
}

console.log(instance.seconds);
instance.seconds -= 1;
console.log(this.seconds);
this.seconds -= 1;
}, 1000);
};

Expand Down