-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (34 loc) · 1.33 KB
/
index.js
File metadata and controls
38 lines (34 loc) · 1.33 KB
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
const userInput = require('./userInput');
const arithmetic = require('./arithmetic');
const vowelCounting = require('./vowelCounting');
function printWelcomeMessage() {
console.log('Welcome to the calculator!');
console.log('==============================');
}
function getCalculationMode(arithmeticMode, vowelCountingMode) {
let response;
let validCalculationModes = [arithmeticMode, vowelCountingMode];
let chosenCalculationMode;
do {
response = userInput.getNumberInputWithPrompt(`Which calculator mode do you want?
${arithmeticMode}) Arithmetic
${vowelCountingMode}) Vowel counting`);
chosenCalculationMode = validCalculationModes.includes(response);
if (chosenCalculationMode == false){
console.log(`"${response}" is not a valid calculation mode, please try again.`);
}
} while (chosenCalculationMode == false);
return response;
}
function startUp(){
printWelcomeMessage();
const arithmeticMode = 1;
const vowelCountingMode = 2;
const calculationMode = getCalculationMode(arithmeticMode, vowelCountingMode);
if (calculationMode === arithmeticMode) {
arithmetic.performOneArithmeticCalculation();
} else if (calculationMode === vowelCountingMode) {
vowelCounting.performOneVowelCountingCalculation();
}
}
startUp();