Skip to content

Commit

Permalink
Beginner - Reduce but Grow
Browse files Browse the repository at this point in the history
  • Loading branch information
PheRum committed Jun 15, 2024
1 parent 67a4420 commit 5e34207
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
10 changes: 10 additions & 0 deletions 8_kyu/Beginner - Reduce but Grow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Beginner - Reduce but Grow

https://www.codewars.com/kata/57f780909f7e8e3183000078

Given a non-empty array of integers, return the result of multiplying the values together in order. Example:

```js
[1, 2, 3, 4] => 1 * 2 * 3 * 4 = 24

```
9 changes: 9 additions & 0 deletions 8_kyu/Beginner - Reduce but Grow/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { grow } from "./index";

describe("Tests", () => {
it("example", () => {
expect(grow([1, 2, 3])).toBe(6);
expect(grow([4, 1, 1, 1, 4])).toBe(16);
expect(grow([2, 2, 2, 2, 2, 2])).toBe(64);
});
});
3 changes: 3 additions & 0 deletions 8_kyu/Beginner - Reduce but Grow/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function grow(x: number[]): number {
return x.reduce((prev, cur) => prev * cur, 1);
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

### Katas solved

`Total`: 103 \
`8_kyu`: 86 \
`Total`: 104 \
`8_kyu`: 87 \
`7_kyu`: 13 \
`6_kyu`: 4 \
`5_kyu`: 0 \
Expand Down
1 change: 0 additions & 1 deletion kata.md

This file was deleted.

0 comments on commit 5e34207

Please sign in to comment.