From 714780ab48bf8978d25264b1918efeb902c72fe5 Mon Sep 17 00:00:00 2001 From: Alexandra Koren Date: Wed, 15 Apr 2020 11:55:44 -0700 Subject: [PATCH 1/3] finished week 1 homework --- src/components/DivElement.js | 11 +++++++++-- src/components/HTMLElement.js | 13 ++++++++++++- src/rolodex/rolodexPrinter.js | 13 ++++++------- src/timer/Timer.js | 29 +++++++++++++++-------------- 4 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/components/DivElement.js b/src/components/DivElement.js index 7e22bcb..25f0652 100644 --- a/src/components/DivElement.js +++ b/src/components/DivElement.js @@ -1,5 +1,12 @@ // Import HTMLElement here - +import HTMLElement from './HTMLElement'; // Define class here - +class DivElement extends HTMLElement { + constructor(content) { + super(); + this.tag = 'div'; + this.content = content; + } +} // Export class here +export default DivElement; diff --git a/src/components/HTMLElement.js b/src/components/HTMLElement.js index 559b785..1cd21b7 100644 --- a/src/components/HTMLElement.js +++ b/src/components/HTMLElement.js @@ -1,4 +1,15 @@ // Define class here +class HTMLElement { + constructor(tag, content) { + this.tag = tag; + this.content = content; + } + + render() { + // eslint-disable-next-line no-console + return `<${this.tag}>${this.content}`; + } +} // Export class here -export default {}; +export default HTMLElement; diff --git a/src/rolodex/rolodexPrinter.js b/src/rolodex/rolodexPrinter.js index 0f12389..c989c5f 100644 --- a/src/rolodex/rolodexPrinter.js +++ b/src/rolodex/rolodexPrinter.js @@ -1,11 +1,10 @@ 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; - - console.log('First name: ' + firstName + '\nLast name: ' + lastName + '\nEmail: ' + email + '\nPhone number: ' + phone + '\n'); + const [firstName, lastName] = names; + const { email } = person; + const { phone } = person; + // eslint-disable-next-line no-console + console.log(`First name: ${firstName} \nLast name: ${lastName} \nEmail: ${email} \nPhone number: ${phone} \n`); }); diff --git a/src/timer/Timer.js b/src/timer/Timer.js index 2453ed9..d82ea72 100644 --- a/src/timer/Timer.js +++ b/src/timer/Timer.js @@ -1,17 +1,18 @@ -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); + } + // eslint-disable-next-line no-console + console.log(this.seconds); + this.seconds -= 1; + }, 1000); + } +} export default Timer; From 5f3717f940582f45605be4cb85b613cd7951ffdf Mon Sep 17 00:00:00 2001 From: Alexandra Koren Date: Wed, 15 Apr 2020 12:06:01 -0700 Subject: [PATCH 2/3] testing pushing from command line --- src/timer/runTimer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/timer/runTimer.js b/src/timer/runTimer.js index 29db01e..0319454 100644 --- a/src/timer/runTimer.js +++ b/src/timer/runTimer.js @@ -1,4 +1,4 @@ import Timer from './Timer'; const countdown = new Timer(10); -countdown.start(); +countdown.start() From 6cc71f0cd6df8a4b93fedba3be4c8d602f8d5df6 Mon Sep 17 00:00:00 2001 From: Alexandra Koren Date: Wed, 15 Apr 2020 12:07:51 -0700 Subject: [PATCH 3/3] testing second time --- src/timer/runTimer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/timer/runTimer.js b/src/timer/runTimer.js index 0319454..29db01e 100644 --- a/src/timer/runTimer.js +++ b/src/timer/runTimer.js @@ -1,4 +1,4 @@ import Timer from './Timer'; const countdown = new Timer(10); -countdown.start() +countdown.start();