Class basic syntax
hannaA
Posted on July 30, 2022
user => first name and last name, return full name as a String
class User{
constructor(name, lastName){
this.name = name;
this.lastName = lastName;
}
get fullName(){
return this.name + " " + this.lastName;
}
}
var user = new User("", "");
console.log(user.fullName);
media => TvShows, movies, (episode, season), (duration)
class Media{
constructor(name, year, imdb){
this.name = name;
this.year = year;
this.imdb = imdb;
}
}
class Tvshows extends Media{
constructor(name, year, imdb, episodes, seasons){
super(name, year, imdb);
this.episodes = episodes;
this.seasons = seasons;
}
}
class Movies extends Media{
constructor(name, year, imdb, duration){
super(name, year, imdb);
this.duration = duration;
}
}
find the mileage of the car
class Car {
constructor (year) {
this.year = year;
}
getAge(now){
return now - this.year;
}
}
let mini = new Car(2018)
console.log(mini.getAge(2022));
💖 💪 🙅 🚩
hannaA
Posted on July 30, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
react Axios NPM Package: A Beginner's Guide to Installing and Making HTTP Requests
November 30, 2024