From 1a3f06f0e364b7f33bcffec1b05cc2ff3bb85d9e Mon Sep 17 00:00:00 2001 From: Alvaro Date: Fri, 10 Nov 2023 20:16:17 +0100 Subject: [PATCH] reto#30 - javascript --- .../javascript/almarro1.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/almarro1.js diff --git a/Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/almarro1.js b/Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/almarro1.js new file mode 100644 index 0000000000..d7646cd4cc --- /dev/null +++ b/Retos/Reto #30 - EL TECLADO T9 [Media]/javascript/almarro1.js @@ -0,0 +1,34 @@ +const translations = { + '2': 'A', + '22': 'B', + '222': 'C', + '3': 'D', + '33': 'E', + '333': 'F', + '4': 'G', + '44': 'H', + '444': 'I', + '5': 'J', + '55': 'K', + '555': 'L', + '6': 'M', + '66': 'N', + '666': 'O', + '7': 'P', + '77': 'Q', + '777': 'R', + '7777': 'S', + '8': 'T', + '88': 'U', + '888': 'V', + '9': 'W', + '99': 'X', + '999': 'Y', + '9999': 'Z', +}; + +function translate(sequence) { + return sequence.split('-').map(x => translations[x]).join(''); +} + +console.log(`6-666-88-777-33-3-33-888 -> ${translate('6-666-88-777-33-3-33-888')}`) \ No newline at end of file