Skip to content

Commit e6134e2

Browse files
committed
Solución Reto 6
1 parent c12bf18 commit e6134e2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

retos/reto-6/main.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function maxDistance(movements) {
2+
let distance = 0
3+
4+
let right = movements.match(/>/g)?.length ?? 0
5+
let left = movements.match(/</g)?.length ?? 0
6+
7+
distance += right
8+
distance -= left
9+
10+
let extra = movements.length - (right + left)
11+
12+
return Math.abs(distance) + Math.abs(extra)
13+
}
14+
15+
module.exports = maxDistance

0 commit comments

Comments
 (0)