-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters