Skip to content

Commit

Permalink
UEFA EURO 2016
Browse files Browse the repository at this point in the history
  • Loading branch information
PheRum committed May 18, 2024
1 parent c56b95a commit 36eb3c4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
11 changes: 11 additions & 0 deletions 8_kyu/UEFA EURO 2016/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## UEFA EURO 2016

https://www.codewars.com/kata/57613fb1033d766171000d60

Finish the uefaEuro2016() function so it return string just like in the examples below:

```
uefaEuro2016(['Germany', 'Ukraine'],[2, 0]) // "At match Germany - Ukraine, Germany won!"
uefaEuro2016(['Belgium', 'Italy'],[0, 2]) // "At match Belgium - Italy, Italy won!"
uefaEuro2016(['Portugal', 'Iceland'],[1, 1]) // "At match Portugal - Iceland, teams played draw."
```
9 changes: 9 additions & 0 deletions 8_kyu/UEFA EURO 2016/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { uefaEuro2016 } from "./index";

describe("Tests", () => {
it("example", () => {
expect(uefaEuro2016(["Germany", "Ukraine"], [2, 0])).toBe("At match Germany - Ukraine, Germany won!");
expect(uefaEuro2016(["Belgium", "Italy"], [0, 2])).toBe("At match Belgium - Italy, Italy won!");
expect(uefaEuro2016(["Portugal", "Iceland"], [1, 1])).toBe("At match Portugal - Iceland, teams played draw.");
});
});
14 changes: 14 additions & 0 deletions 8_kyu/UEFA EURO 2016/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export function uefaEuro2016(teams: string[], scores: number[]): string {
const [scoreA, scoreB] = scores;
const teamsJoin = teams.join(" - ");

if (scoreA > scoreB) {
return `At match ${teamsJoin}, ${teams[0]} won!`;
}

if (scoreA < scoreB) {
return `At match ${teamsJoin}, ${teams[1]} won!`;
}

return `At match ${teamsJoin}, teams played draw.`;
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

### Katas solved

`Total`: 36 \
`8_kyu`: 35 \
`Total`: 37 \
`8_kyu`: 36 \
`7_kyu`: 0 \
`6_kyu`: 1 \
`5_kyu`: 0 \
Expand Down

0 comments on commit 36eb3c4

Please sign in to comment.