96 lines
4.3 KiB
Markdown
96 lines
4.3 KiB
Markdown
---
|
|
title: Top rank per group
|
|
id: 595011cba5a81735713873bd
|
|
challengeType: 5
|
|
videoUrl: ''
|
|
localeTitle: Clasificación superior por grupo
|
|
---
|
|
|
|
## Description
|
|
<section id="description"> Tarea: <p> Encuentre los mejores datos clasificados de N en cada grupo, donde se proporciona N como parámetro. El nombre del rango y el grupo también se proporcionan como parámetro. </p> Teniendo en cuenta los siguientes datos: <pre> El
|
|
{nombre: 'Tyler Bennett', id: 'E10297', salario: 32000, departamento: 'D101'},
|
|
{nombre: 'John Rappl', id: 'E21437', salario: 47000, departamento: 'D050'},
|
|
{nombre: 'George Woltman', id: 'E00127', salario: 53500, departamento: 'D101'},
|
|
{nombre: 'Adam Smith', id: 'E63535', salario: 18000, departamento: 'D202'},
|
|
{nombre: 'Claire Buckman', id: 'E39876', salario: 27800, departamento: 'D202'},
|
|
{nombre: 'David McClellan', id: 'E04242', salario: 41500, departamento: 'D101'},
|
|
{nombre: 'Rich Holcomb', id: 'E01234', salario: 49500, departamento: 'D202'},
|
|
{nombre: 'Nathan Adams', id: 'E41298', salario: 21900, departamento: 'D050'},
|
|
{nombre: 'Richard Potter', id: 'E43128', salario: 15900, departamento: 'D101'},
|
|
{nombre: 'David Motsinger', id: 'E27002', salario: 19250, departamento: 'D202'},
|
|
{nombre: 'Tim Sampair', id: 'E03033', salario: 27000, departamento: 'D101'},
|
|
{nombre: 'Kim Arlich', id: 'E10001', salario: 57000, departamento: 'D190'},
|
|
{nombre: 'Timothy Grove', id: 'E16398', salario: 29900, departamento: 'D190'}
|
|
];
|
|
</pre> uno podría clasificar a los 10 mejores empleados en cada departamento llamando a <code>topRankPerGroup(10, data, 'dept', 'salary')</code> Dados los siguientes datos: <pre> El
|
|
{nombre: 'viernes 13', género: 'horror', calificación: 9.9},
|
|
{nombre: "Nightmare on Elm's Street", género: 'horror', calificación: 5.7},
|
|
{nombre: 'Titanic', género: 'drama', calificación: 7.3},
|
|
{nombre: 'Maze Runner', género: 'scifi', calificación: 7.1},
|
|
{nombre: 'Blade runner', género: 'scifi', calificación: 8.9}
|
|
];
|
|
</pre> uno podría clasificar la película mejor calificada en cada género llamando a <code>topRankPerGroup(1, data, 'genre', 'rating')</code> </section>
|
|
|
|
## Instructions
|
|
<section id="instructions">
|
|
</section>
|
|
|
|
## Tests
|
|
<section id='tests'>
|
|
|
|
```yml
|
|
tests:
|
|
- text: <code>topRankPerGroup</code> es una función.
|
|
testString: 'assert(typeof topRankPerGroup === "function", "<code>topRankPerGroup</code> is a function.");'
|
|
- text: <code>topRankPerGroup</code> devuelve undefined en n valores negativos.
|
|
testString: 'assert(typeof topRankPerGroup(-1, []) === "undefined", "<code>topRankPerGroup</code> returns undefined on negative n values.");'
|
|
- text: El primer departamento debe ser D050
|
|
testString: 'assert.equal(res1[0][0].dept, "D050", "First department must be D050");'
|
|
- text: El primer departamento debe ser D050
|
|
testString: 'assert.equal(res1[0][1].salary, 21900, "First department must be D050");'
|
|
- text: El último departamento debe ser D202.
|
|
testString: 'assert.equal(res1[3][3].dept, "D202", "The last department must be D202");'
|
|
- text: '<code>topRankPerGroup(1, ...)</code> debe devolver solo el resultado de clasificación superior por grupo.'
|
|
testString: 'assert.equal(res2[2].length, 1, "<code>topRankPerGroup(1, ...)</code> must return only top ranking result per group.");'
|
|
- text: '<code>topRankPerGroup(1, ...)</code> debe devolver solo el resultado de clasificación superior por grupo.'
|
|
testString: 'assert.equal(res3[2][1].name, "Maze Runner", "<code>topRankPerGroup(1, ...)</code> must return only top ranking result per group.");'
|
|
|
|
```
|
|
|
|
</section>
|
|
|
|
## Challenge Seed
|
|
<section id='challengeSeed'>
|
|
|
|
<div id='js-seed'>
|
|
|
|
```js
|
|
function topRankPerGroup(n, data, groupName, rankName) {
|
|
// Good luck!
|
|
return true;
|
|
}
|
|
|
|
```
|
|
|
|
</div>
|
|
|
|
|
|
### After Test
|
|
<div id='js-teardown'>
|
|
|
|
```js
|
|
console.info('after the test');
|
|
```
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
## Solution
|
|
<section id='solution'>
|
|
|
|
```js
|
|
// solution required
|
|
```
|
|
</section>
|