-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
354f0fc
commit 082c1f1
Showing
3 changed files
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* eslint-disable space-before-function-paren */ | ||
/* eslint-disable no-unused-vars */ | ||
|
||
// Algorirmo: | ||
// 1- Cojer coda letra de cada gift y ver si esta entre las letra de los materiales | ||
// 2- Si esta entonces meter ese gift en un array | ||
// 3- Devolver el array con los gifts que se pueden fabricar | ||
function manufacture(gifts, materials) { | ||
return gifts.filter((gift) => { | ||
return gift.split('').every((letter) => materials.includes(letter)) | ||
}) | ||
} | ||
|
||
const gifts = ['tren', 'oso', 'pelota'] | ||
const materials = 'tronesa' | ||
|
||
console.log(manufacture(gifts, materials)) |