In: Computer Science
Write a JavaScript program to read and analyze the assessment results of a unit under Node.js host environment. The assessment results are read from the keyboard. The input consists of a list of student results. Each student's result includes the student's name and his or her mark for that unit. These results must be stored in one or several arrays. The input ends when the user types "end".
Once all assessment results are read in, your program should produce a table that summarises the number of students in each grade (HD, D, C, P and N) as well as the percentage of students in each grade. Finally, display the name and mark of the best student.
After the summary table and the best student are displayed, your program prompts the user to inquire about a student's mark. For example, if the user enters the name "John", your program should display the names and marks of all students whose names contain the string "John" (ignore the case).
Your program should allow the user to keep making queries until the user types "stop".
Test and run the above program using Node.js only. Do not use a web browser to test and run your program.
Hints: you may use multiple console.logs to output the data in table-like manner. However, it would be difficulty to make the data in the table properly aligned. Alternatively, you may place the data in a JavaScript object and output the object using console.table. Eg:
(where var hd, d, c, p = number of students in each grade and hdp, dp, cp, pp = percentage of students in each grade)
var hd = ;
var d = ;
var c = ;
var p = ;
var hdp = ;
var dp = ;
var cp = ;
var pp = ;
var table = {};
table.HD = { number: hd, '%': hdp };
table.D = { number: d, '%': dp };
table.C = { number: c, '%': cp };
table.P = { number: p, '%': pp };
console.table (table);