-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4287 from s0alken/javascript
Reto #30 - JavaScript
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/s0alken.js
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,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')) | ||
|
||
|