-
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
5 changed files
with
44 additions
and
3 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,14 @@ | ||
## How good are you really? | ||
|
||
https://www.codewars.com/kata/5601409514fc93442500010b | ||
|
||
There was a test in your class and you passed it. Congratulations! | ||
|
||
But you're an ambitious person. You want to know if you're better than the average student in your class. | ||
|
||
You receive an array with your peers' test scores. Now calculate the average and compare your score! | ||
|
||
Return true if you're better, else false! | ||
|
||
Note: | ||
Your points are not included in the array of your class's points. Do not forget them when calculating the average score! |
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,23 @@ | ||
import { betterThanAverage } from "./index"; | ||
|
||
describe("Tests", () => { | ||
it("betterThanAverage([2, 3], 5) should return True", () => { | ||
expect(betterThanAverage([2, 3], 5)).toBe(true); | ||
}); | ||
|
||
it("betterThanAverage([100, 40, 34, 57, 29, 72, 57, 88], 75) should return True", () => { | ||
expect(betterThanAverage([100, 40, 34, 57, 29, 72, 57, 88], 75)).toBe(true); | ||
}); | ||
|
||
it("betterThanAverage([12, 23, 34, 45, 56, 67, 78, 89, 90], 9) should return False", () => { | ||
expect(betterThanAverage([12, 23, 34, 45, 56, 67, 78, 89, 90], 9)).toBe(false); | ||
}); | ||
|
||
it("betterThanAverage([41, 75, 72, 56, 80, 82, 81, 33], 50) should return False", () => { | ||
expect(betterThanAverage([41, 75, 72, 56, 80, 82, 81, 33], 50)).toBe(false); | ||
}); | ||
|
||
it("betterThanAverage([29, 55, 74, 60, 11, 90, 67, 28], 21) should return False", () => { | ||
expect(betterThanAverage([29, 55, 74, 60, 11, 90, 67, 28], 21)).toBe(false); | ||
}); | ||
}); |
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,5 @@ | ||
export function betterThanAverage(classPoints: number[], yourPoints: number): boolean { | ||
const average = classPoints.reduce((a, b) => a + b, 0) / classPoints.length; | ||
|
||
return average <= yourPoints; | ||
} |
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
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