From d5c22ad51aff853a020bdc623583c651da95b59a Mon Sep 17 00:00:00 2001 From: David TEIXEIRA Date: Tue, 20 Sep 2022 18:39:00 +0200 Subject: [PATCH 1/4] maj 1 --- index.js | 86 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index 9b48491..220698a 100644 --- a/index.js +++ b/index.js @@ -15,25 +15,39 @@ console.log('🚀 It Works!'); // 📝 TODO: Number of filming locations // 1. Make the function return the number of filming locations function getFilmingLocationsNumber () { - return '' + return new Set(filmingLocations).size; } -console.log(`There is ${getFilmingLocationsNumber()} filming locations in Paris`) +//console.log(`There is ${getFilmingLocationsNumber()} filming locations in Paris`); // 📝 TODO: Filming locations sorted by start date, from most recent to oldest. // 1. Implement the function // 2. Log the first and last item in array +function compare (a, b) +{ + return new Date(b.fields.date_debut) - new Date(a.fields.date_debut) ; +} function sortFilmingLocationsByStartDate () { - return '' + return filmingLocations.sort(compare); } -console.log(``) +/*let a =sortFilmingLocationsByStartDate() +console.log(a[0]) +console.log(a[a.length-1])*/ // 📝 TODO: Number of filming locations in 2020 only // 1. Make the function return the number of filming locations in 2020 only // 2. Log the result + function getFilmingLocationsNumber2020 () { - return '' + let a = 0 + for (let i=0;i Date: Tue, 20 Sep 2022 18:44:15 +0200 Subject: [PATCH 2/4] maj 1.1 --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 220698a..64bda70 100644 --- a/index.js +++ b/index.js @@ -124,12 +124,13 @@ function getFilmingLocationsNumberDistrict(district) { let nb = 0 for (let i=0;i Date: Tue, 20 Sep 2022 19:02:55 +0200 Subject: [PATCH 3/4] maj 1.2 --- index.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 64bda70..38c4113 100644 --- a/index.js +++ b/index.js @@ -120,16 +120,15 @@ function getFilmingLocationsNumberPerDistrict () { // 1. Implement the function, result expected as an array of object like: // const result = [{film: 'LRDM - Patriot season 2', locations: 12}, {...}] // 2. Log the first and last item of the array -function getFilmingLocationsNumberDistrict(district) { - let nb = 0 - for (let i=0;i Date: Tue, 27 Sep 2022 15:47:00 +0200 Subject: [PATCH 4/4] maj 1.3 --- index.js | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 38c4113..687229a 100644 --- a/index.js +++ b/index.js @@ -122,30 +122,56 @@ function getFilmingLocationsNumberPerDistrict () { // 2. Log the first and last item of the array function getFilmLocationsByFilm () { + let result =[] let noms_film = [] for (let i = 0; i < filmingLocations.length; i++) { let film = filmingLocations[i].fields.nom_tournage if (!(noms_film.includes(film))) noms_film.push(film) } - let result =[] + for(let i=0;i