JSFiddle - React, Tailwind, and code Playground

by lavisha99

JavaScript

/*Narrative:

You have been asked to conduct a study on academic performance for the course INFOSYS 123. As a first step, you need to record the student's age (a number between 16 and 35), nationality and grade (a score between 0 and 100). The university carrying the study wants to keep the anonymity of the students, thus you must not store any information that can reveal the identity of the student such as name or student ID. In the end, you need to display the average score of the whole class.

1st: Write a set of concise instructions to complete this task.

Constraints:

You must store the information for each student in a separate object.
You must provide fictitious data for five students.
You cannot use loops for calculating the average.
 */
 

let total=0;
let studentInfo=[{name:'f',grade:20},{name:'p', grade:10},{name:'d' ,grade:30} ];
 console.log(studentInfo);

 for( let i= 0; i< studentInfo.length; i++) {
total += studentInfo[i].grade;
}
console.log(total/3);
  let student=[];
  let studentArray=[];
 for(i=0; i<100; i++) {
  student={age:Math.floor(Math.random()*19+16), grade:
  Math.floor(Math.random()*100+1)};
  studentArray.push(student);
 }
 console.log(studentArray);