Skip to content

Commit 6f1ceb9

Browse files
committed
completed runProgram function to display word and score
1 parent c2e31a4 commit 6f1ceb9

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

scrabble-scorer.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,21 @@ function scorerPrompt() {
9292
while (scorerProgramIndex < 0 || scorerProgramIndex > 2 || isNaN(scorerProgramIndex)) {
9393
scorerProgramIndex = input.question(`Please enter a number from 0-2. What scoring algorithym would you like to use? ${scorerOptions}`);
9494
}
95-
return scoringAlgorithms[scorerProgramIndex];
95+
return scoringAlgorithms[scorerProgramIndex].scorerFunction;
9696
};
9797
// create an array with the scorer functions, from the user input, call the relavant algorithym and print the word and score
9898

9999
function transform() { };
100100

101101
function runProgram() {
102-
initialPrompt();
103-
scorerPrompt();
104-
105-
// Somehow I need to take the returned index from the user's response and call the selected algorithym, printing the word and score
102+
let wordInput = initialPrompt();
103+
let scorerFunction = scorerPrompt();
104+
let score = scorerFunction(wordInput);
105+
console.log(`Score for'${wordInput}': ${score}`);
106106
}
107-
console.log("algorithym name: ", scoringAlgorithms[2].name);
108-
console.log("scorerFunction result: ", scoringAlgorithms[2].scorerFunction('JavaScript'));
107+
// console.log("algorithym name: ", scoringAlgorithms[2].name);
108+
// console.log("scorerFunction result: ", scoringAlgorithms[2].scorerFunction('JavaScript'));
109+
109110
// Don't write any code below this line //
110111
// And don't change these or your program will not run as expected //
111112
module.exports = {

0 commit comments

Comments
 (0)