diff --git a/app.js b/app.js new file mode 100644 index 0000000..05ad396 --- /dev/null +++ b/app.js @@ -0,0 +1,40 @@ +// Import readline-sync +const readline = require("readline-sync"); + +// Ask for the user's name +let userName = readline.question("What is your name? "); + +// Greet the user +console.log(`\nHello, ${userName}! Let's test your knowledge of Values, Data Types, and Operations.\n`); + +// Ask 5 questions +let favoriteDataType = readline.question( + "1. What is your favorite JavaScript data type? " +); + +let numberValue = Number( + readline.question( + "2. Enter a number: " + ) +); + +let booleanValue = readline.question( + "3. What value represents 'true' or 'false' in JavaScript? " +); + +let additionOperator = readline.question( + "4. Which operator is used for addition in JavaScript? " +); + +let stringValue = readline.question( + "5. What data type is used to store text? " +); + +// Print the user's answers +console.log("\n----- Your Answers -----"); +console.log(`Name: ${userName}`); +console.log(`Favorite Data Type: ${favoriteDataType}`); +console.log(`Number Entered: ${numberValue}`); +console.log(`Boolean Answer: ${booleanValue}`); +console.log(`Addition Operator: ${additionOperator}`); +console.log(`Text Data Type: ${stringValue}`); diff --git a/node_modules/readline-sync/index.js b/node_modules/readline-sync/index.js new file mode 100644 index 0000000..d5ad88f --- /dev/null +++ b/node_modules/readline-sync/index.js @@ -0,0 +1,18 @@ +const readline = require('readline'); + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + +function question(prompt) { + return new Promise((resolve) => { + rl.question(prompt, (answer) => { + resolve(answer); + }); + }); +} + +module.exports = { + question +}; diff --git a/readline.txt b/readline.txt new file mode 100644 index 0000000..8439f6f --- /dev/null +++ b/readline.txt @@ -0,0 +1,2 @@ +npm install readline-sync +const readline = require(readline-sync); diff --git a/tasks.txt b/tasks.txt index f48e33d..8eb1a6f 100644 --- a/tasks.txt +++ b/tasks.txt @@ -1 +1,2 @@ -# To-Do List +npm install readline-sync +const readline = require('readline-sync');