Skip to content
Snippets Groups Projects
Commit b33900d8 authored by Andrej Rasevic's avatar Andrej Rasevic
Browse files

adding first module example

parent f18793f7
No related branches found
No related tags found
No related merge requests found
const modules = require('./person')
console.log(modules)
let p1 = new modules.Person("Jessica", 35)
let s1 = new modules.Stu("Amy", 3.5)
console.log(p1.toString())
console.log(s1.toString())
class Person {
constructor(name, age){
this.name = name;
this.age = age;
}
toString(){
return "Name is: " + this.name + " age is " +this.age;
}
}
class Student {
constructor(name, gpa){
this.name = name;
this.gpa = gpa;
}
toString(){
return "Name is: " + this.name + " gpa is " +this.gpa;
}
}
function saySomething(phrase) {
console.log(phrase)
}
module.exports.Person = Person;
module.exports.Stu = Student;
module.exports.saySomething = saySomething;
module.exports = {
Person: Person,
Stu: Student
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment