ES6-Classes-Extends

by Ravindra Athreya

HTML

<div class="wrapWord">
THis is the loooooooooooooooong textTHis is the loooooooooooooooong textTHis is the loooooooooooooooong textTHis is the loooooooooooooooong textTHis is the loooooooooooooooong textTHis is the loooooooooooooooong textTHis is the loooooooooooooooong textTHis is the loooooooooooooooong textTHis is the loooooooooooooooong textTHis is the loooooooooooooooong textTHis is the loooooooooooooooong textTHis is the loooooooooooooooong textTHis is the loooooooooooooooong text
</div>

CSS

.wrapWord {
  width: 100px;
  border: 1px solid red;
  word-wrap: break-word;
  }

JavaScript

class Person {
constructor(name = "Unknown", age = 33) {
this.name = name;
this.age = age;
}
getDetails() {
return `Hey i am ${this.name} and i am ${this.age}`
}
}

class Student extends Person {
constructor(name,age,major="Undecided") {
super(name,age);
this.major = major;
}

getDetails() {
let message = super.getDetails();
message += `. My Major is ${this.major}`;
return message;
}
}

const me = new Student("Ravi", 34, "CS");

 /* alert(me.getDetails()); */