-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjava2.html
37 lines (34 loc) · 1.15 KB
/
java2.html
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
37
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h2>JAVA SCRIPT CLASS</h2>
<P id="DEMO"></P>
<P id="DEMO2"></P>
<script>
class student{
constructor(fname,lname,birthyear){
this.fname=fname;
this.lname=lname;
this.birthyear=birthyear;
}
age(x){
return x-this.birthyear;
}
fullname()
{
return this.fname+" "+this.lname;
}
}
let date=new Date();
return date.getFullYear()-this.birthyear;
student1=new student("ABISH","RAVI",2021);
student2=new student("SHESHAN","RAJa",2018);
document.getElementById('DEMO').innerHTML=student1.fullname()+""+" ,HIS AGE IS "+student1.age(year);
document.getElementById('DEMO2').innerHTML=student2.fullname()+""+" ,HIS AGE IS"+student2.age(year);
</script>
</body>
</html>