From 119a13bcaa0bd917986db4f39ee96c092e82c228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ad=C3=A8lebp?= Date: Wed, 1 Apr 2020 15:21:13 +0200 Subject: [PATCH 1/6] 1st ex map --- map/ex1.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/map/ex1.js b/map/ex1.js index 323e1028..e3543d84 100644 --- a/map/ex1.js +++ b/map/ex1.js @@ -25,8 +25,17 @@ Expected OUTPUT for this sample array: ] */ +const words = ['Chicken', 'Bacon', 'Tofu', 'Mayonnaise']; + + function getStringsLength(strings) { + return strings.map(function(words){ + return words + ' contains ' + words.length + ' characters'; + + }); + + } // If you need, you can always visualize the result with a console.log. From 211104ad537ca9e77b5d2d7cdda16161af3a514d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ad=C3=A8lebp?= Date: Wed, 1 Apr 2020 16:10:26 +0200 Subject: [PATCH 2/6] 2dn ex map --- map/ex2.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/map/ex2.js b/map/ex2.js index 99a2a2f1..51d778cc 100644 --- a/map/ex2.js +++ b/map/ex2.js @@ -32,6 +32,8 @@ Sample foods array, i.e. INPUT: } ] + + Expected OUTPUT for this sample [ 'Bacon is not suitable for vegetarians', @@ -43,9 +45,19 @@ Expected OUTPUT for this sample */ function getFoodCategories(foods) { -} + return foods.map(aliment => { + if (aliment.isVegetarian === true){ + return (aliment.food + ' is suitable for vegetarians') + + } else { + return (aliment.food + ' is not suitable for vegetarians') + } + }) +} + + // DON'T TOUCH THIS! module.exports = getFoodCategories; From 49915b300d9e763eb1ea92b5a3bf49030a3f9a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ad=C3=A8lebp?= Date: Wed, 1 Apr 2020 16:18:05 +0200 Subject: [PATCH 3/6] 3rd ex map --- map/ex3.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/map/ex3.js b/map/ex3.js index 6a1c5960..6512928d 100644 --- a/map/ex3.js +++ b/map/ex3.js @@ -61,10 +61,20 @@ Expected OUTPUT for this sample: */ + function getMoviesFreshness(movies) { + return movies.map(movie => { + if (movie.rating < 60){ + movie.label = 'rotten' + } else if (movie.rating >= 60 && movie.rating <= 75){ + movie.label = 'fresh' + } else { + movie.label = 'certified fresh' + } + return movie + }) } - // DON'T TOUCH THIS! module.exports = getMoviesFreshness; From 78d6d102f53b33cb2c4a323a3950616c9256bd91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ad=C3=A8lebp?= Date: Wed, 1 Apr 2020 16:37:24 +0200 Subject: [PATCH 4/6] 1st ex filter --- filter/ex1.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/filter/ex1.js b/filter/ex1.js index fa4f3d80..dbc12a8d 100644 --- a/filter/ex1.js +++ b/filter/ex1.js @@ -13,7 +13,9 @@ Expected OUTPUT for this sample: */ + function getPositiveNumbers(numbers) { + return numbers.filter(numbers => numbers >= 0) } // If you need, you can always visualize the result with a console.log. From 75f5c86555f872f104c4d414ed905e13893836ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ad=C3=A8lebp?= Date: Wed, 1 Apr 2020 16:38:07 +0200 Subject: [PATCH 5/6] 2nd ex filter --- filter/ex2.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/filter/ex2.js b/filter/ex2.js index 5bc423e3..55488d8d 100644 --- a/filter/ex2.js +++ b/filter/ex2.js @@ -26,7 +26,9 @@ Expected OUTPUT for this sample: */ function keepStarks(names) { -} + return names.filter(names => names.endsWith('Stark') + + )} // DON'T TOUCH THIS! module.exports = keepStarks; From 4c89deb67f11750816a3198e519be6fa32e1dcdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ad=C3=A8lebp?= Date: Wed, 1 Apr 2020 16:44:47 +0200 Subject: [PATCH 6/6] 3rd ex filter --- filter/ex3.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/filter/ex3.js b/filter/ex3.js index 1076cf80..9a234bd2 100644 --- a/filter/ex3.js +++ b/filter/ex3.js @@ -33,6 +33,10 @@ Expected OUTPUT for these sample arguments: */ function filterOnPrice(products, maxPrice) { + + return products.filter(price => price.price <= maxPrice) + + } // DON'T TOUCH THIS!