Skip to content

hw complete #15

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
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
"node": true,
"jest": true
}

}
12 changes: 12 additions & 0 deletions src/components/DivElement.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
// Import HTMLElement here
import HTMLElement from './HTMLElement';

// Define class here
class DivElement extends HTMLElement {
constructor(content) {
/* this line refers to the HTMLElement Class */
/* meaning that it's invoking it with the set parameters */
super('div', content);
}
}

// const newDiv = new DivElement('Hello World!');
// console.log(newDiv.render());

// Export class here
export default DivElement;
16 changes: 15 additions & 1 deletion src/components/HTMLElement.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
// Define class here
class HTMLElement {
constructor(tag, content) {
this.tag = tag;
this.content = content;
}

render() {
const element = `<${this.tag}>${this.content}</${this.tag}>`;
return element;
}
}

// const test = new HTMLElement('h1', 'Hello World!');
// console.log(test.render());

// Export class here
export default {};
export default HTMLElement;
15 changes: 15 additions & 0 deletions src/pythonIdentationTest/pythonTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# this is a test for the indentation of python code using 2 space indentation

def hello():
return "hello world"

print(hello())

def addition(a,b):
sum = a +b
return sum

print(addition(2,2))


# Summary: no errors are caused by new indentation rule
20 changes: 12 additions & 8 deletions src/rolodex/rolodexPrinter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
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;
const information = () => {
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 response = `First name: ${firstName} \nLast name: ${lastName} \nEmail: ${email} \nPhone number: + ${phone} \n`;
return response;
});
};

console.log('First name: ' + firstName + '\nLast name: ' + lastName + '\nEmail: ' + email + '\nPhone number: ' + phone + '\n');
});
information();
48 changes: 35 additions & 13 deletions src/timer/Timer.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
function Timer(seconds) {
this.seconds = seconds;
}
// function Timer(seconds) {
// this.seconds = seconds;
// }

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

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);
// };
// return timerInterval;
// };

console.log(instance.seconds);
instance.seconds -= 1;
}, 1000);
};
class Timer {
constructor(seconds) {
this.seconds = seconds;
}

start() {
/* this is the equivalent of let seconds = this.seconds
but this is as an object */
let { seconds } = this.seconds;
const timerInterval = setInterval(() => {
if (seconds === 0) {
clearInterval(timerInterval);
} else {
seconds -= 1;
}
}, 1000);
}
}

export default Timer;