Skip to content

Commit 7c373b0

Browse files
[ADD] add module
1 parent 9d494e8 commit 7c373b0

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

ECMAScript/A07-Module/export.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export const PI = Math.PI;
2+
3+
export function degreesToRadians(degree) {
4+
return degree * PI / 180;
5+
}
6+
7+
export class Circle {
8+
constructor(radius) {
9+
this.radius = radius;
10+
}
11+
12+
area() {
13+
return PI * this.radius * this.radius;
14+
}
15+
}

ECMAScript/A07-Module/import.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {PI, Circle, degreesToRadians} from "./export.js";
2+
3+
let radian = degreesToRadians(90);
4+
console.log(radian);
5+
6+
let myCircle = new Circle(2);
7+
let myArea = myCircle.area();
8+
console.log("myArea: " + myArea);

ECMAScript/A07-Module/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "A07-Module",
3+
"version": "1.0.0",
4+
"type": "module",
5+
"dependencies": {
6+
}
7+
}

0 commit comments

Comments
 (0)