Scrabble Scorer Step 1
The context: this is an exercise that was given to me in a coding boot camp. The solution was compiled in a JavaScript file in repl.it and the user interaction was within the terminal.
The Prompt
We have been instructed to update the old Scrabble scorer algorithm with these five steps:
- initialPrompt: ask the user which scoring algorithm they wish to use
- transformFunction: as the name suggests, transforms the oldPointStructure and returns a newPointStructure
- Construct three different scoring algorithms(each will be an object with 3 key/value pairs(not sure how this is going to work/look at this point)
- scoringAlgorithmsArray: initialize this array
- runProgam: tie it all together
This seems like a huge feat and I have no idea how to get from where I'm at (zero code) to having a fully function program that does all of the things listed above. But hopefully by taking this into chunks it will seem more like a sequence of hills than Mt Everest.
initialPrompt
- Ask the user which scoring algorithm they wish to use
This will require a readline-sync. The code for this is:
const input = require("readline-sync");
let info = input.question("Question text...");
We want the prompt to be: [ Welcome to the Scrabble score calculator! Which scoring algorithm would you like to use? 0 - Scrabble: The traditional scoring algorithm. 1 - Simple Score: Eash letter is worth 1 point. 2 - Bonus Vowels: Vowels are worth 3 pts, and consonants are 1 pt.
Enter 0, 1, or 2: ]
The code for this would look like:
let initialPrompt = function() {
const input = require("readline-sync");
let info = input.question(`Welcome to the Scrabble score calculator!
Which scoring algorithm would you like to use?
0 - Scrabble: The traditional scoring algorithm.
1 - Simple Score: Each letter is worth 1 point.
2 - Bonus Vowels: Vowels are worth 3 pts, and consonants are 1 pt.
Enter 0, 1, or 2: `);
}
initialPrompt();
I use a template literal here so I don't have to enter (/n) every time I want a new line.
Woah. Done with the first step.
The following steps are coming soon! :)