From 7a9c4723d6cd511b286ebea1de68a4c0024a9e8b Mon Sep 17 00:00:00 2001 From: gikf <60067306+gikf@users.noreply.github.com> Date: Fri, 5 Mar 2021 12:31:40 +0100 Subject: [PATCH] fix: move test data to seed code for convenience --- .../rosetta-code/top-rank-per-group.md | 60 ++++++++----------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/curriculum/challenges/english/10-coding-interview-prep/rosetta-code/top-rank-per-group.md b/curriculum/challenges/english/10-coding-interview-prep/rosetta-code/top-rank-per-group.md index e9376eba96..17c3329347 100644 --- a/curriculum/challenges/english/10-coding-interview-prep/rosetta-code/top-rank-per-group.md +++ b/curriculum/challenges/english/10-coding-interview-prep/rosetta-code/top-rank-per-group.md @@ -10,43 +10,11 @@ dashedName: top-rank-per-group Find the top `n` ranked data in each group, where `n` is provided as a parameter. Name of the rank and the group are also provided as parameter. -Given the following data: - -```js -testData1 = [ - { name: 'Tyler Bennett', id: 'E10297', salary: 32000, dept: 'D101' }, - { name: 'John Rappl', id: 'E21437', salary: 47000, dept: 'D050' }, - { name: 'George Woltman', id: 'E00127', salary: 53500, dept: 'D101' }, - { name: 'Adam Smith', id: 'E63535', salary: 18000, dept: 'D202' }, - { name: 'Claire Buckman', id: 'E39876', salary: 27800, dept: 'D202' }, - { name: 'David McClellan', id: 'E04242', salary: 41500, dept: 'D101' }, - { name: 'Rich Holcomb', id: 'E01234', salary: 49500, dept: 'D202' }, - { name: 'Nathan Adams', id: 'E41298', salary: 21900, dept: 'D050' }, - { name: 'Richard Potter', id: 'E43128', salary: 15900, dept: 'D101' }, - { name: 'David Motsinger', id: 'E27002', salary: 19250, dept: 'D202' }, - { name: 'Tim Sampair', id: 'E03033', salary: 27000, dept: 'D101' }, - { name: 'Kim Arlich', id: 'E10001', salary: 57000, dept: 'D190' }, - { name: 'Timothy Grove', id: 'E16398', salary: 29900, dept: 'D190' } -]; -``` - -one could rank top 10 employees in each department by calling +Given the `testData1` one could rank top 10 employees in each department by calling: `topRankPerGroup(10, testData1, 'dept', 'salary')` -Given the following data: - -```js -testData2 = [ - { name: 'Friday 13th', genre: 'horror', rating: 9.9 }, - { name: "Nightmare on Elm's Street", genre: 'horror', rating: 5.7 }, - { name: 'Titanic', genre: 'drama', rating: 7.3 }, - { name: 'Maze Runner', genre: 'scifi', rating: 7.1 }, - { name: 'Blade runner', genre: 'scifi', rating: 8.9 } -]; -``` - -one could rank the top-rated movie in each genre by calling +Given the `testData2` one could rank the top-rated movie in each genre by calling: `topRankPerGroup(1, testData2, 'genre', 'rating')` @@ -154,6 +122,30 @@ function topRankPerGroup(n, data, groupName, rankName) { return true; } + + +const testData1 = [ + { name: 'Tyler Bennett', id: 'E10297', salary: 32000, dept: 'D101' }, + { name: 'John Rappl', id: 'E21437', salary: 47000, dept: 'D050' }, + { name: 'George Woltman', id: 'E00127', salary: 53500, dept: 'D101' }, + { name: 'Adam Smith', id: 'E63535', salary: 18000, dept: 'D202' }, + { name: 'Claire Buckman', id: 'E39876', salary: 27800, dept: 'D202' }, + { name: 'David McClellan', id: 'E04242', salary: 41500, dept: 'D101' }, + { name: 'Rich Holcomb', id: 'E01234', salary: 49500, dept: 'D202' }, + { name: 'Nathan Adams', id: 'E41298', salary: 21900, dept: 'D050' }, + { name: 'Richard Potter', id: 'E43128', salary: 15900, dept: 'D101' }, + { name: 'David Motsinger', id: 'E27002', salary: 19250, dept: 'D202' }, + { name: 'Tim Sampair', id: 'E03033', salary: 27000, dept: 'D101' }, + { name: 'Kim Arlich', id: 'E10001', salary: 57000, dept: 'D190' }, + { name: 'Timothy Grove', id: 'E16398', salary: 29900, dept: 'D190' } +]; +const testData2 = [ + { name: 'Friday 13th', genre: 'horror', rating: 9.9 }, + { name: "Nightmare on Elm's Street", genre: 'horror', rating: 5.7 }, + { name: 'Titanic', genre: 'drama', rating: 7.3 }, + { name: 'Maze Runner', genre: 'scifi', rating: 7.1 }, + { name: 'Blade runner', genre: 'scifi', rating: 8.9 } +]; ``` # --solutions--