From 29732faeca969678437d8bfcb3c96809572c57ad Mon Sep 17 00:00:00 2001 From: Samyak Shah Date: Sun, 3 Oct 2021 01:08:55 +0530 Subject: [PATCH] DOCS: build question added --- buildlogic/que1.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 buildlogic/que1.js diff --git a/buildlogic/que1.js b/buildlogic/que1.js new file mode 100644 index 0000000..833cac6 --- /dev/null +++ b/buildlogic/que1.js @@ -0,0 +1,35 @@ +// Create a CLI app which takes name, unit test marks, pre final marks, final marks of 5 students. And then print who has the highest marks. What if I ask you to print the average as well? + + +// add readlineSync package +var readlineSync = require('readline-sync'); + +// array of questions +var questions = ["Enter your name " , "Enter unit test marks " , "Enter preFinal marks " , "Enter final marks "] + +var highest = 0; +var ranker = "" + + +// for loop +for(var i=0; i< 5; i++){ + + var userName = readlineSync.question(questions[0]); + var unitMarks = readlineSync.question(questions[1]); + var preFinal = readlineSync.question(questions[2]); + var final = readlineSync.question(questions[3]); + + var sum = Number(unitMarks) + Number(preFinal) + Number(final) + + var avg = (sum) / 3 + + console.log(userName + " your Average marks from all three test is " + avg) + +if(sum > highest){ + highest = sum + ranker = userName +} +} + +console.log("Highest scorer is: " + ranker + " whose total is: " + highest) +