diff --git a/Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/s0alken.js b/Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/s0alken.js new file mode 100644 index 0000000000..55c61fe2a7 --- /dev/null +++ b/Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/s0alken.js @@ -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')) + +