Skip to content

Commit

Permalink
Merge pull request #4287 from s0alken/javascript
Browse files Browse the repository at this point in the history
Reto #30 - JavaScript
  • Loading branch information
kontroldev authored Jul 25, 2023
2 parents ca9abbb + 57a2620 commit c4887dc
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/s0alken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const decodeMessage = (pressed) => {

keys = [
' 0',
'.?!1',
'ABC2',
'DEF3',
'GHI4',
'JKL5',
'MNO6',
'PQRS7',
'TUV8',
'WXYZ9',
]

return pressed.split('-').reduce((message, sequence) => {
const number = Number(sequence[0]);
const char = sequence.length - 1;
message += keys[number][char];
return message;
}, '')
}

console.log(decodeMessage('6-666-88-777-33-3-33-888'))


0 comments on commit c4887dc

Please sign in to comment.