-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2-q.html
36 lines (31 loc) · 928 Bytes
/
2-q.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Q 2</title>
<script type="text/javascript">
// write a function that returns the number of its own calls
function countCalls() {
console.log(countCalls.currantCount);
// 2
// 1
countCalls.currantCount = (countCalls.currantCount || 0); // Makes it into an object
console.log(typeof countCalls.currantCount);
console.log(typeof countCalls);
// 0
// ++ 0 = 1
// 1
// 1 + 1 = 2
// 2
// 1 + 2 = 3
// 3
return alert("You called " + ++countCalls.currantCount); // ++ before to get it to call from nr 1
}
countCalls(); // You called 1
countCalls(); // You called 2
countCalls(); // You called 3
</script>
</head>
<body>
</body>
</html>