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
10 changes: 9 additions & 1 deletion src/components/DivElement.js
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(content);
Copy link

@t1mwillis t1mwillis Apr 24, 2020

Choose a reason for hiding this comment

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

Suggested change
super(content);
super('div', content);

Then you can remove the two lines below this.

this.tag = 'div';
this.content = content;
}
}

// Export class here
export default DivElement;
12 changes: 11 additions & 1 deletion src/components/HTMLElement.js
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;
13 changes: 6 additions & 7 deletions src/rolodex/rolodexPrinter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
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(([name, email, phone] = [people.name, people.email, people.phone]) => {

Choose a reason for hiding this comment

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

This is one way to do it!

I was thinking more like

people.forEach(({name, email, phone}) => {
  const [firstName, lastName] = name.split[' ']
  return `First name: ${firstName}
    Last name: ${lastName}
    Email: ${email}
    Phone number: ${phone}`;
})

const { firstName, lastName } = name.split(' ');
Copy link

@t1mwillis t1mwillis Apr 24, 2020

Choose a reason for hiding this comment

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

This will not work, name.split returns an array.
const [firstName, lastName] = name.split(' ')

Copy link
Author

Choose a reason for hiding this comment

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

ah.. dang. I was judging success by 'npm test'. I don't think I actually tried to run any of them individually. 😳


console.log('First name: ' + firstName + '\nLast name: ' + lastName + '\nEmail: ' + email + '\nPhone number: ' + phone + '\n');
return `First name: ${firstName}
Last name: ${lastName}
Email: ${email}
Phone number: ${phone}`;
});
27 changes: 13 additions & 14 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);
}
class Timer {
constructor(seconds) {
this.seconds = seconds;
}

console.log(instance.seconds);
instance.seconds -= 1;
}, 1000);
};
start() {
const timerInterval = setInterval(() => {
if (this.seconds === 0) {
clearInterval(timerInterval);
}
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


export default Timer;