forked from mouredev/retos-programacion-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
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 mouredev#6055 from RNatsuki/main
Reto#47 - JavaScript
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [Fácil]/javascript/RNatusuki.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,21 @@ | ||
const readline = require("readline"); | ||
|
||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout, | ||
}); | ||
|
||
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(); | ||
}); |