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
320 changes: 320 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions src/every.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
// ]
// Expected Output: true
function allNutritious (items) {

return items.every((element)=>{
return (element.nutritious===true);
})
}

// Sample Input:
Expand All @@ -19,7 +21,14 @@ function allNutritious (items) {
// ]
// Expected Output: false
function allOfOneType (items) {

return items.every((element, index, items)=>{
let type = typeof(items[0]);
if(type ==="object"){
return
}
return (type === typeof(element))

})
}

module.exports = { allNutritious, allOfOneType }
8 changes: 6 additions & 2 deletions src/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Sample Input: [ 11, 44, 78, 99 ]
// Expected Output: [ 11, 44 ]
function onlyOdd (numbers) {

return numbers.filter(element => element % 2 !== 0)
}

// Sample Input:
Expand All @@ -16,7 +16,11 @@ function onlyOdd (numbers) {
// Expected Output:
// { id: 42, name: 'Clojure' }
function findById (languages, id) {

let array = languages.filter(element => {
console.log(element.id);
return element.id === id;
})
return array[0]|| null;
}

module.exports = { onlyOdd, findById }
6 changes: 4 additions & 2 deletions src/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// ]
// Expected Output: ['Alex Mali', 'dvsn', 'Mura Masa']
function justArtists (songs) {

return songs.map(el => el.artist);
}

// Sample Input:
Expand All @@ -24,7 +24,9 @@ function justArtists (songs) {
// { name: 'Banana Bunches', price: 2.33, quantity: 2 }
// ]
function toObject (candies) {

return candies.map(candy => {
return {name: candy[0],price: candy[1], quantity: candy[2]};
});
}

module.exports = { justArtists, toObject }
Loading