-
Notifications
You must be signed in to change notification settings - Fork 514
/
scrabble-scorer.js
71 lines (52 loc) · 1.68 KB
/
scrabble-scorer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// This assignment is inspired by a problem on Exercism (https://exercism.org/tracks/javascript/exercises/etl) that demonstrates Extract-Transform-Load using Scrabble's scoring system.
const input = require("readline-sync");
const oldPointStructure = {
1: ['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T'],
2: ['D', 'G'],
3: ['B', 'C', 'M', 'P'],
4: ['F', 'H', 'V', 'W', 'Y'],
5: ['K'],
8: ['J', 'X'],
10: ['Q', 'Z']
};
function oldScrabbleScorer(word) {
word = word.toUpperCase();
let letterPoints = "";
for (let i = 0; i < word.length; i++) {
for (const pointValue in oldPointStructure) {
if (oldPointStructure[pointValue].includes(word[i])) {
letterPoints += `Points for '${word[i]}': ${pointValue}\n`
}
}
}
return letterPoints;
}
// your job is to finish writing these functions and variables that we've named //
// don't change the names or your program won't work as expected. //
function initialPrompt() {
console.log("Let's play some scrabble! Enter a word:");
};
let newPointStructure;
let simpleScorer;
let vowelBonusScorer;
let scrabbleScorer;
const scoringAlgorithms = [];
function scorerPrompt() {}
function transform() {};
function runProgram() {
initialPrompt();
}
// Don't write any code below this line //
// And don't change these or your program will not run as expected //
module.exports = {
initialPrompt: initialPrompt,
transform: transform,
oldPointStructure: oldPointStructure,
simpleScorer: simpleScorer,
vowelBonusScorer: vowelBonusScorer,
scrabbleScorer: scrabbleScorer,
scoringAlgorithms: scoringAlgorithms,
newPointStructure: newPointStructure,
runProgram: runProgram,
scorerPrompt: scorerPrompt
};