Skip to content

Commit c2e31a4

Browse files
committed
improved scorerPrompt function to print algorithym object and return a score
1 parent 43a2073 commit c2e31a4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

scrabble-scorer.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,17 @@ const scoringAlgorithms = [
7272
{
7373
"name": "Simple Score",
7474
"description": "Each letter is worth 1 point.",
75-
"scorerFunction": simpleScorer()
75+
"scorerFunction": simpleScorer
7676
},
7777
{
7878
"name": "Vowel Bonus",
7979
"description": "Vowels are 3 points.",
80-
"scorerFunction": vowelBonusScorer()
80+
"scorerFunction": vowelBonusScorer
8181
},
8282
{
8383
"name": "Scrabble",
8484
"description": "Uses scabble point system.",
85-
"scorerFunction": oldScrabbleScorer()
85+
"scorerFunction": oldScrabbleScorer
8686
}
8787
];
8888

@@ -92,7 +92,7 @@ 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
95+
return scoringAlgorithms[scorerProgramIndex];
9696
};
9797
// create an array with the scorer functions, from the user input, call the relavant algorithym and print the word and score
9898

@@ -101,10 +101,11 @@ function transform() { };
101101
function runProgram() {
102102
initialPrompt();
103103
scorerPrompt();
104-
104+
105105
// Somehow I need to take the returned index from the user's response and call the selected algorithym, printing the word and score
106106
}
107-
107+
console.log("algorithym name: ", scoringAlgorithms[2].name);
108+
console.log("scorerFunction result: ", scoringAlgorithms[2].scorerFunction('JavaScript'));
108109
// Don't write any code below this line //
109110
// And don't change these or your program will not run as expected //
110111
module.exports = {

0 commit comments

Comments
 (0)