Vellore Institute of Technology
SITE ITE1002
Develop a small application for the Basketball scoreboard using Node.js event handling. Here, we have a scoreKeeper.on() eventlistener listening for an event that would indicate a basket being made. Each scoring attempt is a call of the shoot_a_basket function. If the ball goes in the net (indicated by a true value for the shot), s
...[Show More]
Develop a small application for the Basketball scoreboard using Node.js event handling. Here, we have a scoreKeeper.on() eventlistener listening for an event that would indicate a basket being made. Each scoring attempt is a call of the shoot_a_basket function. If the ball goes in the net (indicated by a true value for the shot), scoreKeeper.emit() is called, which alerts all event-listeners listening for the make_basket event announcement to run their callback function, and passes the value of the basket made. Display the scores of each team. const events = require('events'); const scoreKeeper = new events.EventEmi&er(); var score1 = 0; var score2 = 0; func8on make_basket(team){ if(team==="A"){ score1 += 1; }else{ score2 += 1; } console.log("Score of team A is" + score1); console.log("Score of team B is" + score2); console.log("--------------------------"); } scoreKeeper.on('make_basket',make_basket); func8on scored(team){ scoreKeeper.emit('make_basket',team); } scored("A"); scored("B"); scored("A"); scored("A"); scored("B"); scored("A"); 3. Create a MongoDB “Student” database and do the following operations: A. Insert a new student with a name: Dora B. Insert a new student with a name: Sinchan and id=2 (integer) C. Insert a new student with a name: Angush, the midterm score of 80, and a final score of 100. Scores should be embedded in a sub-document like this: scores:{midterm:0,final:0}. D. Finding a document by a single attribute as name as “your name”. E. Display the list of students who scored between greater than 50 in the midterm. F. Search for students that have scored between [50,80] in midterm AND [80,100] in the final exam. G. Update the student Sinchan that you created back in exercise 2 to have a midterm score of 50 and a final score of 100 respectively. H. Sort according to the final score in descending order and display name and score without objectID. A) Insert a new student with a name: Dora B) Insert a new student with a name: Sinchan and id=2 (integer) C) Insert a new student with a name: Angush, the midterm score of 80, and a final score of 100. Scores should be embedded in a sub-document like this: scores: {midterm:0,final:0}.
[Show Less]