diff --git a/package.json b/package.json index e05edcb..103b051 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,6 @@ "eslint": "^6.8.0", "eslint-config-airbnb-base": "^14.1.0", "eslint-plugin-import": "^2.20.2", - "jest": "^25.2.7" + "jest": "^25.2.7" } } diff --git a/src/components/DivElement.js b/src/components/DivElement.js index 7e22bcb..9944c05 100644 --- a/src/components/DivElement.js +++ b/src/components/DivElement.js @@ -1,5 +1,14 @@ // Import HTMLElement here +import HTMLElement from './HTMLElement'; // Define class here +class DivElement extends HTMLElement { + constructor(content) { + super('div', content); + } +} + + // Export class here +export { DivElement as default }; diff --git a/src/components/HTMLElement.js b/src/components/HTMLElement.js index 559b785..11a7e38 100644 --- a/src/components/HTMLElement.js +++ b/src/components/HTMLElement.js @@ -1,4 +1,14 @@ // Define class here +class HTMLElement { + constructor(tag, content) { + this.tag = tag; + this.content = content; + } + + render() { + return `<${this.tag}>${this.content}`; + } +} // Export class here -export default {}; +export { HTMLElement as default }; diff --git a/src/rolodex/rolodexPrinter.js b/src/rolodex/rolodexPrinter.js index 0f12389..bf6accd 100644 --- a/src/rolodex/rolodexPrinter.js +++ b/src/rolodex/rolodexPrinter.js @@ -1,11 +1,8 @@ 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) => { + const [firstName, lastName] = person.name.split(' '); + 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`); }); diff --git a/src/timer/Timer.js b/src/timer/Timer.js index 2453ed9..656c8ca 100644 --- a/src/timer/Timer.js +++ b/src/timer/Timer.js @@ -1,17 +1,19 @@ -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(this.seconds); + } - console.log(instance.seconds); - instance.seconds -= 1; - }, 1000); -}; + start() { + const timerInterval = setInterval(() => { + if (this.seconds === 0) { + clearInterval(timerInterval); + } + console.log(this.seconds); + this.seconds -= 1; + }, 0.0000001); + } +} export default Timer; diff --git a/src/timer/runTimer.js b/src/timer/runTimer.js index 29db01e..cdb53e4 100644 --- a/src/timer/runTimer.js +++ b/src/timer/runTimer.js @@ -2,3 +2,4 @@ import Timer from './Timer'; const countdown = new Timer(10); countdown.start(); +console.log(countdown); diff --git a/test/DivElement.spec.js b/test/DivElement.spec.js index f34069a..3aac7b4 100644 --- a/test/DivElement.spec.js +++ b/test/DivElement.spec.js @@ -9,6 +9,7 @@ describe('DivElement class', () => { }); it('should be a class with the name DivElement', () => { + console.log(instance); expect(instance.constructor.name).toContain('DivElement'); });