diff --git a/index.js b/index.js index 9b48491..5108646 100644 --- a/index.js +++ b/index.js @@ -5,6 +5,9 @@ const filmingLocations = require('./lieux-de-tournage-a-paris.json') console.log('🚀 It Works!'); +const e1 = getFilmingLocationsNumber(); +const e2 = sortFilmingLocationsByStartDate(); +//console.log(getFilmingLocationsNumber2020()); /** * 💅 Try to produce the most readable code, use meaningful variable names @@ -15,7 +18,7 @@ console.log('🚀 It Works!'); // 📝 TODO: Number of filming locations // 1. Make the function return the number of filming locations function getFilmingLocationsNumber () { - return '' + return filmingLocations.length } console.log(`There is ${getFilmingLocationsNumber()} filming locations in Paris`) @@ -23,17 +26,31 @@ console.log(`There is ${getFilmingLocationsNumber()} filming locations in Paris` // 1. Implement the function // 2. Log the first and last item in array function sortFilmingLocationsByStartDate () { - return '' + + return } -console.log(``) +//console.log(sortFilmingLocationsByStartDate()) // 📝 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 count = 0; + + for(let i = 0; i < filmingLocations.length; i++){ + if(filmingLocations[i].fields.annee_tournage == "2020"){ + count++; + } + } + return count; +} +console.log('Ex1: '+getFilmingLocationsNumber2020()); + +function getFilmLocationNumber(){ + + } -console.log() + // 📝 TODO: Number of filming locations per year // 1. Implement the function, the expected result is an object with years as @@ -44,9 +61,39 @@ console.log() // } // 2. Log the result function getFilmingLocationsNumberPerYear () { - return {} + let count = 0; + let tab = []; + const years_ = ["2016", "2017", "2018", "2019", "2020", "2021"]; + + for(let i = 0; i