-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcarcolor.html
More file actions
36 lines (36 loc) · 857 Bytes
/
carcolor.html
File metadata and controls
36 lines (36 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<html>
<head>
<title> Inherit the properties from the parent Person class. code by sedmachine </title>
<body>
<script>
class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}
sing() {
return ${this.name} can sing;
}
dance() {
return ${this.name} can dance;
}
}
class Child extends Person {
constructor(name, age, Color) {
super(name, age);
this.Color = Color;
}
car() {
return "I have"+" "+this.Color+" "+" Color Car";
}
}
var a = window. prompt("Enter The Person Name: ");
var b = window. prompt("Enter The Person Age: ");
var c = window. prompt("Enter The Person Car Color: ");
let obj = new Child(a, b, c);
console.log(obj.sing());
console.log(obj.car());
</script>
</body>
</head>
</html>