Skip to content
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
12 changes: 12 additions & 0 deletions src/components/DivElement.js
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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but is not required. The super('div', content) sets the content.

}
}

// Export class here
export default DivElement;

const andIThinkToMyself = new DivElement('What a wonderful world');

console.log(andIThinkToMyself.render());
16 changes: 15 additions & 1 deletion src/components/HTMLElement.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
// 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;

const lovelaceQuote = new HTMLElement('p', 'I am never so happy as when I am really engaged in good earnest...');
console.log(lovelaceQuote.render());
14 changes: 7 additions & 7 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;
people.forEach((person) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
people.forEach((person) => {
people.forEach(({ email, phone, name }) => {

You can destructure your arguments. Saves a few lines, but isn't always the most readable 🤷‍♀️

const { email, phone } = person;
const [firstName, lastName] = person.name.split(' ');

console.log('First name: ' + firstName + '\nLast name: ' + lastName + '\nEmail: ' + email + '\nPhone number: ' + phone + '\n');
console.log(`First name: ${firstName}
Last name: ${lastName}
Email: ${email}
Phone number: ${phone}`);
});
29 changes: 14 additions & 15 deletions src/timer/Timer.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
function Timer(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);
};
class Timer {
constructor(seconds) {
this.seconds = seconds;
}

start() {
const timerInterval = setInterval(() => {
if (this.seconds === 0) {
clearInterval(timerInterval);
}
console.log(this.seconds);
this.seconds -= 1;
}, 1000);
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work here.

export default Timer;