Skip to content

Commit f99d526

Browse files
authored
Fix gamePoints solution
1 parent 6b65003 commit f99d526

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/exercises/08-more-arrays-solutions.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ process.stdout.write('\n*8·72.\n');
556556
/*
557557
*8·72. Create a function called 'gamePoints' that takes an array of game results and returns the total points, according to the following description. Each game result is a pair of scores: [home team score, away team score]. Games where the home team won are worth 3 points. Games where the home team lost are worth 0 points. Tie games are worth 1 point.
558558
*/
559-
const gamePoints = ([homeScore, awayScore]) => {
559+
const points = ([homeScore, awayScore]) => {
560560
if (homeScore > awayScore) {
561561
return 3;
562562
} else if (homeScore < awayScore) {
@@ -565,13 +565,13 @@ const gamePoints = ([homeScore, awayScore]) => {
565565
return 1;
566566
}
567567
};
568-
const points = games => games.reduce((total, game) => total + gamePoints(game), 0);
568+
const gamePoints = games => games.reduce((total, game) => total + points(game), 0);
569569

570-
console.log('points tests');
571-
console.log(points([ [1, 0], [2, 0], [3, 0] ]) === 9);
572-
console.log(points([ [1, 1], [2, 2], [3, 3] ]) === 3);
573-
console.log(points([ [0, 1], [0, 2], [0, 3] ]) === 0);
574-
console.log(points([ [1, 0], [4, 2], [3, 2], [2, 3], [2, 2], [0, 2] ]) === 10);
570+
console.log('gamePoints tests');
571+
console.log(gamePoints([ [1, 0], [2, 0], [3, 0] ]) === 9);
572+
console.log(gamePoints([ [1, 1], [2, 2], [3, 3] ]) === 3);
573+
console.log(gamePoints([ [0, 1], [0, 2], [0, 3] ]) === 0);
574+
console.log(gamePoints([ [1, 0], [4, 2], [3, 2], [2, 3], [2, 2], [0, 2] ]) === 10);
575575

576576

577577
process.stdout.write('\n');

0 commit comments

Comments
 (0)