mirror of
https://github.com/zhigang1992/example-npm.git
synced 2026-01-12 17:13:20 +08:00
Co-authored-by: Steve Winton <stevewinton@gmail.com> Co-authored-by: Steve Winton <swinton@users.noreply.github.com> Co-authored-by: Brandon Keepers <bkeepers@github.com>
32 lines
360 B
JavaScript
32 lines
360 B
JavaScript
const scores = {
|
|
A: 1,
|
|
B: 3,
|
|
C: 3,
|
|
D: 2,
|
|
E: 1,
|
|
F: 4,
|
|
G: 2,
|
|
H: 4,
|
|
I: 1,
|
|
J: 8,
|
|
K: 5,
|
|
L: 1,
|
|
M: 3,
|
|
N: 1,
|
|
O: 1,
|
|
P: 3,
|
|
Q: 10,
|
|
R: 1,
|
|
S: 1,
|
|
T: 1,
|
|
U: 1,
|
|
V: 4,
|
|
W: 4,
|
|
X: 8,
|
|
Y: 4,
|
|
Z: 10
|
|
};
|
|
|
|
module.exports.score = async word =>
|
|
word.split('').reduce((previous, current) => previous + scores[current.toUpperCase()], 0);
|