Skip to content

Commit a07307e

Browse files
committed
Seance2.1
1 parent e8b49b0 commit a07307e

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

index.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,34 @@ console.log('🚀 It Works!');
1515
// 📝 TODO: Number of filming locations
1616
// 1. Make the function return the number of filming locations
1717
function getFilmingLocationsNumber () {
18-
return ''
18+
const keyCount = Object.keys(filmingLocations).length;
19+
return keyCount;
1920
}
2021
console.log(`There is ${getFilmingLocationsNumber()} filming locations in Paris`)
2122

2223
// 📝 TODO: Filming locations sorted by start date, from most recent to oldest.
2324
// 1. Implement the function
2425
// 2. Log the first and last item in array
25-
function sortFilmingLocationsByStartDate () {
26-
return ''
26+
function sortFilmingLocationsByStartDate (filmArray) {
27+
return filmArray.sort(function(a, b){
28+
return a.fields.date_debut - b.fields.date_debut;
29+
});
2730
}
28-
console.log(``)
31+
const resultat1 = sortFilmingLocationsByStartDate(filmingLocations);
32+
console.log(resultat1[0].fields.date_debut,resultat1[resultat1.length-1].fields.date_debut)
2933

3034
// 📝 TODO: Number of filming locations in 2020 only
3135
// 1. Make the function return the number of filming locations in 2020 only
3236
// 2. Log the result
33-
function getFilmingLocationsNumber2020 () {
34-
return ''
37+
function getFilmingLocationsNumber2020 (filmArray) {
38+
39+
const result= filmArray.map(function(film) {
40+
if(film.fields.annee_tournage == 2020)
41+
return film;
42+
});
43+
return sortFilmingLocationsByStartDate(result)
3544
}
36-
console.log()
45+
console.log(getFilmingLocationsNumber2020(filmingLocations))
3746

3847
// 📝 TODO: Number of filming locations per year
3948
// 1. Implement the function, the expected result is an object with years as

0 commit comments

Comments
 (0)