-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise.js
More file actions
54 lines (36 loc) · 1.08 KB
/
exercise.js
File metadata and controls
54 lines (36 loc) · 1.08 KB
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
function ageCalculator(current,birth) {
var yourAge = current - birth;
var yourAge2 = yourAge -1;
document.write("<br>");
document.write("You are either " + yourAge + " or " + yourAge2)
}
ageCalculator(2019, 2000)
// Basic 3 | Age Calculator-improved
function ageCalculator(birth) {
var year = new Date();
var current = year.getFullYear();
var yourAge = current - birth;
var yourAge2 = yourAge -1;
console.log(year);
document.write("<br>");
document.write("You are either " + yourAge + " or " + yourAge2);
}
ageCalculator(2000)
// Basic 4 | Degree-Radian Conversion
function convertDegree(degree) {
var oneRadian = Math.PI / 180;
var result = oneRadian * degree;
document.write("<br>");
document.write(result);
}
// Basic 5 | Area and Volume of a box
function getArea(length,width) {
var resultArea = length * width;
return resultArea;
console.log(resultArea);
}
var firstResult = resultArea;
function getVolume(depth) {
var resultVolume = firstResult * depth;
console.log(resultVolume);
}