Skip to content

Commit 3d7d3c1

Browse files
committed
Array Prototype
1 parent c6655ef commit 3d7d3c1

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Array.prototype.calculate = function(inputArr, callBackFunc){
2+
let outputArr = [];
3+
for(let index=0; index < inputArr.length; index++){
4+
outputArr.push(callBackFunc(inputArr[index]));
5+
}
6+
return outputArr;
7+
}
8+
9+
10+
const radius = [1, 2, 3, 4, 5];
11+
12+
console.log(radius);
13+
14+
const calculateArea = function(radius){
15+
return Math.PI * radius * radius;
16+
}
17+
18+
const areaList = radius.calculate(radius, calculateArea);
19+
20+
console.log(areaList)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Prototype of Array</title>
8+
</head>
9+
<body>
10+
<h3>Array Prototype</h3>
11+
<ul>
12+
<li></li>
13+
</ul>
14+
15+
<script src="./Array.js" defer></script>
16+
</body>
17+
</html>

0 commit comments

Comments
 (0)