Skip to content

Instantly share code, notes, and snippets.

@arun-ghontale
Created June 9, 2018 11:17
Show Gist options
  • Save arun-ghontale/5a03c2867ee3ad1ae41ab8fa72776de7 to your computer and use it in GitHub Desktop.
Save arun-ghontale/5a03c2867ee3ad1ae41ab8fa72776de7 to your computer and use it in GitHub Desktop.
class student{
constructor(student_args){
/* Of the format
{
name:"",
city:"".
gender:"",
work:"",
age:""
}
*/
this.name = student_args.name
this.city = student_args.city
this.gender = student_args.gender
this.work = student_args.work
this.age = student_args.age
}
get_details(){
return [this.name,this.city,this.gender,this.work,this.age]
}
}
class tvb{
constructor(args){
let each;
this.student_class = {}
for (each=0;each<args.length;each++){
this.student_class["student"+String(each)] = new student(args[each])
}
}
get_details(){
return this.student_class
}
}
inputs = [{name:"arun ghontale",city:"bangalore",gender:"male",work:"ML",age:"22"},{name:"vijay rangan",city:"bangalore",gender:"male",work:"FS",age:"29"}]
console.log("TVB_class")
TVB = new tvb(inputs)
TVB.get_details()
console.log("student class")
console.log(TVB.student_class)
let each = 0;
for (each = 0;each < TVB.student_class.length; each++){
console.log(TVB.student_class[each])
console.log(TVB.student_class.get_details())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment