Skip to content

Commit fafa42c

Browse files
committed
feat(calculator.ts): add cos method
1 parent 625d369 commit fafa42c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/Calculator.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,9 @@ export default class Calculator {
6161
this.current = Math.sin(this.current);
6262
return this;
6363
}
64+
65+
public cos() {
66+
this.current = Math.cos(this.current);
67+
return this;
68+
}
6469
}

tests/Calculator.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ describe("Calculator", () => {
1717

1818
it("can clear", () => expect(calculator.clear().value()).equal(0));
1919
it("can sin", () => expect(calculator.sin().value()).equal(0));
20+
it("can cos", () => expect(calculator.cos().value()).equal(1));
2021

2122
it("has the correct initial value when no argument is supplied", () => expect(new Calculator().value()).equal(0));
2223
it("has the correct initial value when an argument is supplied", () => expect(new Calculator(3).value()).equal(3));

0 commit comments

Comments
 (0)