diff --git a/.eslintrc.json b/.eslintrc.json index bfb117c..86c568e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -3,5 +3,8 @@ "env": { "node": true, "jest": true + }, + "rules": { + "linebreak-style": 0 } } \ No newline at end of file diff --git a/src/components/DivElement.js b/src/components/DivElement.js index e66604c..6c83c45 100644 --- a/src/components/DivElement.js +++ b/src/components/DivElement.js @@ -1,6 +1,15 @@ const HTMLElement = require('./HTMLElement'); // Define class here +class DivElement extends HTMLElement { + constructor(content) { + super('div', content); + } +} + +// let foo = new DivElement('hello'); +// let divString = foo.render(); +// console.log(divString); // Export class here -module.exports = {}; +module.exports = DivElement; diff --git a/src/components/HTMLElement.js b/src/components/HTMLElement.js index cae2e29..a1a2757 100644 --- a/src/components/HTMLElement.js +++ b/src/components/HTMLElement.js @@ -1,4 +1,17 @@ // Define class here +class HTMLElement { + constructor(tag, content) { + this.tag = tag; + this.content = content; + } + render() { + return `<${this.tag}>${this.content}`; + } +} + +// let foo = new HTMLElement('p', 'hello'); +// let htmlString = foo.render(); +// console.log(htmlString); // Export class here -module.exports = {}; +module.exports = HTMLElement; diff --git a/src/timer/Timer.js b/src/timer/Timer.js index 03851f2..1255a70 100644 --- a/src/timer/Timer.js +++ b/src/timer/Timer.js @@ -1,17 +1,17 @@ -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); + } + console.log(this.seconds); + this.seconds -= 1; + }, 1000); + } +} module.exports = Timer;