Skip to content

Week 1 Assignment #8

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 4 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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "week1",
"type": "module",
"version": "1.0.0",
"description": "Week 1 Assignment",
"main": "index.js",
Expand Down
15 changes: 12 additions & 3 deletions src/components/DivElement.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
// Import HTMLElement here
import HTMLElement from "./HTMLElement.js";

// Define class here
console.log(HTMLElement); //
class DivElement extends HTMLElement { //ESLint
constructor(content) {
super('div', content);
}
render() {
return `${this.content}`;
}
}
const andIThinkToMyself = new DivElement('What a wonderful world');

// Export class here
console.log(andIThinkToMyself.render());
12 changes: 9 additions & 3 deletions src/components/HTMLElement.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
// Define class here
export default class HTMLElement {
constructor(tag, content) {
this.tag = tag;
this.content = content;
}

// Export class here
export default {};
render() {
return `<${this.tag}>${this.content}</${this.tag}>`;
}
}
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) => {
let names = person.name.split(' ');
let firstName = names[0];
let lastName = names[1];
let email = person.email;
let phone = person.phone;
console.log('First name: ' + firstName + '\nLast name: ' + lastName + '\nEmail: ' + email + '\nPhone number: ' + phone + '\n');
});
7 changes: 3 additions & 4 deletions src/timer/Timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ function Timer(seconds) {
this.seconds = seconds;
}

Timer.prototype.start = function () {
var instance = this;
var timerInterval = setInterval(function () {
Timer.prototype.start = () => {
let instance = this.seconds;
let timerInterval = setInterval(() => {
if (instance.seconds === 0) {
clearInterval(timerInterval);
}
Expand All @@ -13,5 +13,4 @@ Timer.prototype.start = function () {
instance.seconds -= 1;
}, 1000);
};

export default Timer;
2 changes: 1 addition & 1 deletion src/timer/runTimer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Timer from './Timer';

const countdown = new Timer(10);
let countdown = new Timer(10);
countdown.start();