JAVASCRIPT: 39.2 Practice - Array Properties & Methods
In JavaScript course, I am having a hard time to understand one part of the given code. The goal of the program is to get the sum of all gained points for each passed level. Passed level is an input (which will be the length of the array). The next inputs are the points for each level (depending on the length of the array). The way I understand the code below, it appears that the program accepts 3 inputs: - levels - points - elem The question is, what is the purpose of the "elem" variable? I am having a hard time to understand it since I am also practicing these JavaScript exercises using my computer web browser and a text editor (visual studio code). function main() { //take the number of passed levels var levels = parseInt(readLine(),10); var points = new Array(); var count = 0; while(count<levels){ var elem = parseInt(readLine(),10); points[count] = elem; count++; } var sum = 0; //calculate the sum of points //output console.log(sum);