From 1f52259ad864632dc8769c511d54f0529883901c Mon Sep 17 00:00:00 2001 From: Ibarra Date: Mon, 11 Dec 2023 09:11:56 -0600 Subject: [PATCH 1/2] Create RNatusuki.js --- .../javascript/RNatusuki.js" | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 "Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [F\303\241cil]/javascript/RNatusuki.js" diff --git "a/Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [F\303\241cil]/javascript/RNatusuki.js" "b/Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [F\303\241cil]/javascript/RNatusuki.js" new file mode 100644 index 0000000000..1c5c4b38d5 --- /dev/null +++ "b/Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [F\303\241cil]/javascript/RNatusuki.js" @@ -0,0 +1,18 @@ +const readline = require('readline'); + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + +rl.question('Ingresa una palabra: ', (word) => { + const points = word + .split('') + .map((char) => char.charCodeAt(0) - 96) + .map((point) => (point >= 15 ? point + 1 : point)) + .reduce((acc, curr) => acc + curr, 0); + + console.log(`Puntos: ${points}`); + + rl.close(); +}); From 02523df2263190b2682bad73a5b15e90f89e6a8b Mon Sep 17 00:00:00 2001 From: Ibarra Date: Mon, 11 Dec 2023 09:22:30 -0600 Subject: [PATCH 2/2] Update RNatusuki.js --- .../javascript/RNatusuki.js" | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git "a/Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [F\303\241cil]/javascript/RNatusuki.js" "b/Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [F\303\241cil]/javascript/RNatusuki.js" index 1c5c4b38d5..17b9424045 100644 --- "a/Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [F\303\241cil]/javascript/RNatusuki.js" +++ "b/Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [F\303\241cil]/javascript/RNatusuki.js" @@ -1,18 +1,21 @@ -const readline = require('readline'); +const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, - output: process.stdout + output: process.stdout, }); -rl.question('Ingresa una palabra: ', (word) => { - const points = word - .split('') - .map((char) => char.charCodeAt(0) - 96) - .map((point) => (point >= 15 ? point + 1 : point)) - .reduce((acc, curr) => acc + curr, 0); +rl.question("Ingresa una palabra: ", (word) => { + const points = [...word].reduce((acc, char) => { + if (char === "ñ") { + return acc + 15; + } else { + const point = char.charCodeAt(0) - 96; + return acc + (point >= 15 ? point + 1 : point); + } + }, 0); console.log(`Puntos: ${points}`); rl.close(); -}); +}); \ No newline at end of file