-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathdata.js
More file actions
36 lines (32 loc) · 841 Bytes
/
data.js
File metadata and controls
36 lines (32 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Función de Ordenar de la A a la Z
function sortByNameOrTitle(data) {
return data.sort(function (a, b) {
var textA = a.title
? a.title.toUpperCase()
: a.name
? a.name.toUpperCase()
: "";
var textB = b.title
? b.title.toUpperCase()
: b.name
? b.name.toUpperCase()
: "";
return textA < textB ? -1 : textA > textB ? 1 : 0;
});
}
// Función para filtrar por director
function filterByDirector(data, director) {
let moviesByDirector = data.filter(function (film) {
return film.director === director;
});
return moviesByDirector;
}
//Función para obtener un porcentaje
function getAverage(data) {
let result = 0;
data.forEach((e) => {
result += e.rt_score / data.length;
});
return result;
}
export { sortByNameOrTitle, filterByDirector, getAverage };