Skip to content

Commit 4dc832a

Browse files
committed
Solución y Tests del reto 2
1 parent 4583a02 commit 4dc832a

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

retos/reto-2/main.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function manufacture(gifts, materials) {
2+
const mate = materials.split("")
3+
4+
return gifts.filter(g => {
5+
const x = [...new Set([...g, ...mate])]
6+
7+
return x.length == mate.length
8+
})
9+
}
10+
11+
module.exports = manufacture

retos/reto-2/reto2.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const manufacture = require('./main.ts')
2+
3+
test("Test #01 - Returns an Array", () => {
4+
expect(
5+
Array.isArray(
6+
manufacture(['tren', 'oso', 'pelota'], 'tronesa')
7+
)
8+
).toBe(true)
9+
})
10+
11+
test("Test #02 - manufacture(['tren', 'oso', 'pelota'], 'tronesa')", () => {
12+
expect(manufacture(['tren', 'oso', 'pelota'], 'tronesa')).toStrictEqual([
13+
"tren",
14+
"oso"
15+
])
16+
})
17+
18+
19+
test("Test #03 - manufacture(['coche', 'muñeca', 'balon'], 'ocmuñalb')", () => {
20+
expect(manufacture(['coche', 'muñeca', 'balon'], 'ocmuñalb')).toStrictEqual([])
21+
})
22+
23+
test("Test #04 - manufacture(['patineta', 'robot', 'libro'], 'nopor')", () => {
24+
expect(manufacture(['patineta', 'robot', 'libro'], 'nopor')).toStrictEqual([])
25+
})
26+
27+
test("Test #05 - manufacture([], 'letras')", () => {
28+
expect(manufacture([], 'letras')).toStrictEqual([])
29+
})

0 commit comments

Comments
 (0)