Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions filter/ex1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion filter/ex2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 4 additions & 0 deletions filter/ex3.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
9 changes: 9 additions & 0 deletions map/ex1.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 13 additions & 1 deletion map/ex2.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Sample foods array, i.e. INPUT:
}
]



Expected OUTPUT for this sample
[
'Bacon is not suitable for vegetarians',
Expand All @@ -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;
12 changes: 11 additions & 1 deletion map/ex3.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;