diff --git a/package-lock.json b/package-lock.json index 749b59f..6ba1584 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8131,9 +8131,9 @@ "dev": true }, "strip-json-comments": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.0.1.tgz", - "integrity": "sha512-VTyMAUfdm047mwKl+u79WIdrZxtFtn+nBxHeb844XBQ9uMNTuTHdx2hc5RiAJYqwTj3wc/xe5HLSdJSkJ+WfZw==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.0.tgz", + "integrity": "sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w==", "dev": true }, "supports-color": { diff --git a/src/components/DivElement.js b/src/components/DivElement.js index 7e22bcb..8073732 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(content); + this.content = content; + this.tag = 'div'; + } +} // Export class here +export default DivElement; diff --git a/src/components/HTMLElement.js b/src/components/HTMLElement.js index 559b785..f96ac6d 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 default HTMLElement; diff --git a/src/rolodex/rolodexPrinter.js b/src/rolodex/rolodexPrinter.js index 0f12389..09f5b41 100644 --- a/src/rolodex/rolodexPrinter.js +++ b/src/rolodex/rolodexPrinter.js @@ -1,11 +1,9 @@ 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; + const [firstName, lastName] = [names[0], names[1]]; + const { email, phone } = person; - 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}`); }); diff --git a/src/timer/Timer.js b/src/timer/Timer.js index 2453ed9..5e5eb61 100644 --- a/src/timer/Timer.js +++ b/src/timer/Timer.js @@ -1,17 +1,34 @@ -function Timer(seconds) { - this.seconds = seconds; -} +// 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); +// }; -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); + } + + console.log(this.seconds); + this.seconds -= 1; + }, 1000); + } +} export default Timer;