Skip to content

HTMLElement and DivElement test submisison #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
```js
const lovelaceQuote = new HTMLElement('p', 'I am never so happy as when I am really engaged in good earnest...');

console.log(lovelaveQuote.render());
console.log(lovelaceQuote.render());
// prints "<p>I am never so happy as when I am really engaged in good earnest...</p>"
```

Expand Down
11 changes: 7 additions & 4 deletions src/components/DivElement.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// Import HTMLElement here
import HTMLElement from './HTMLElement';

// Define class here

// Export class here
class DivElement extends HTMLElement {
constructor(content) {
super('div', content);
}
}
export default { DivElement };
11 changes: 10 additions & 1 deletion src/components/HTMLElement.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
// 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((person) => {
const { name } = person;
const { email } = person;
const { phone } = person;
const [firstName, lastName] = name.split(' ');

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: ${phone}`);
});
27 changes: 14 additions & 13 deletions src/timer/Timer.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
function Timer(seconds) {
this.seconds = seconds;
}
class Timer {
constructor(seconds) {
this.seconds = seconds;
}

Timer.prototype.start = function () {
var instance = this;
var timerInterval = setInterval(function () {
if (instance.seconds === 0) {
clearInterval(timerInterval);
}
start() {
const startTimer = setInterval(() => {
if (this.seconds === 0) {
clearInterval(startTimer);
}

console.log(instance.seconds);
instance.seconds -= 1;
}, 1000);
};
console.log(this.seconds);
this.seconds -= 1;
}, 1000);
}
}

export default Timer;