Skip to content

Commit 588a034

Browse files
committed
Reto 3 y tests
1 parent 60a2a26 commit 588a034

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

retos/reto-3/main.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function findNaughtyStep(original, modified) {
2+
3+
const [lessWords, mostWords] =
4+
[original, modified].sort((a, b) => a.length - b.length)
5+
6+
return [...mostWords].find((x, i) => [...lessWords][i] != x) ?? ""
7+
}
8+
9+
module.exports = findNaughtyStep

retos/reto-3/reto3.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const findNaughtyStep = require('./main.ts')
2+
3+
test("Test #01 - Returns a String", () => {
4+
expect(
5+
typeof findNaughtyStep('abcd', 'abcde')
6+
).toBe("string")
7+
})
8+
9+
test("Test #02 - findNaughtyStep('abcd', 'abcde')", () => {
10+
expect(findNaughtyStep('abcd', 'abcde')).toStrictEqual("e")
11+
})
12+
13+
test("Test #03 - findNaughtyStep('xxxx', 'xxoxx')", () => {
14+
expect(findNaughtyStep('xxxx', 'xxoxx')).toStrictEqual("o")
15+
})
16+
17+
test("Test #04 - findNaughtyStep('stepfor', 'stepor')", () => {
18+
expect(findNaughtyStep('stepfor', 'stepor')).toStrictEqual("f")
19+
})
20+
21+
test("Test #05 - findNaughtyStep('iiiii', 'iiiii')", () => {
22+
expect(findNaughtyStep('iiiii', 'iiiii')).toStrictEqual("")
23+
})

0 commit comments

Comments
 (0)