Skip to content
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Week 1 Assignment",
"main": "index.js",
"scripts": {
"lint": "eslint ./src",
"lint": "eslint --fix ./src",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄

"test:watch": "jest --watch",
"test": "npm run lint && jest",
"file": "babel-node"
Expand Down
8 changes: 8 additions & 0 deletions src/components/DivElement.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
// Import HTMLElement here
import HTMLElement from './HTMLElement';

// Define class here
class DivElement extends HTMLElement {
constructor(content) {
super('div', content);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

}
}


// Export class here
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;
7 changes: 7 additions & 0 deletions src/components/Untitled.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"folders": [
{
"path": "/Users/i534961/Documents/JS"
}
]
}
11 changes: 3 additions & 8 deletions src/rolodex/rolodexPrinter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
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;

console.log('First name: ' + firstName + '\nLast name: ' + lastName + '\nEmail: ' + email + '\nPhone number: ' + phone + '\n');
people.forEach((element) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
people.forEach((element) => {
people.forEach(({ name, phone, email }) => {

const [firstName, lastName] = element.name.split(' ');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const [firstName, lastName] = element.name.split(' ');
const [firstName, lastName] = name.split(' ');

console.log(`First name: ${firstName}\nLast name: ${lastName}\nEmail: ${element.email}\nPhone number: ${element.phone}\n`);
});
26 changes: 13 additions & 13 deletions src/timer/Timer.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
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);
}

console.log(instance.seconds);
instance.seconds -= 1;
}, 1000);
};
start() {
const timerInterval = setInterval(() => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

if (this.seconds === 0) {
clearInterval(timerInterval);
}

this.seconds -= 1;
}, 1000);
}
}
export default Timer;