-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssignment1-D-O-B-Nested-If.html
68 lines (50 loc) · 1.56 KB
/
Assignment1-D-O-B-Nested-If.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
// Calculate Your Own Age Program (Date of Birth)....
var date = parseInt(prompt("Enter The Date which You are Born "));
var month = parseInt(prompt("Enter The Month which You are Born "));
var year = parseInt(prompt("Enter The Year which You are Born"));
var cdate = parseInt(prompt("Enter The current Date "));
var cmonth = parseInt(prompt("Enter The Current Month "));
var cyear = parseInt(prompt("Enter The current Year "));
var date1 , month1 , year1 ;
if(cdate > date)
{
date1 = cdate - date;
}
else{
// cdate = parseInt(cdate); // Value (string value) convert into integer
cdate += 30;
cmonth --;
date1= cdate - date;
}
if(cmonth> month)
{
month1 = cmonth - month;
}
else{
cmonth += 12;
cyear --;
month1 = cmonth - month;
}
if(cyear > year)
{
year1 = cyear - year;
}
else{
console.log("Enter Valid Birth Year");
}
console.log("Your Date of Birth is : ");
console.log("Date = " + date1 + ", month = " + month1 + ", Year = " + year1);
// console.log( date1 , "-", month1 , "-", year1);
</script>
</body>
</html>