Array Properties And Methods Challenge
Can someone please help me with this challenge. Test case 4 and 5 work but 1,2 and 3 do not. The player receives points after passing each level of a game. The program given takes the number of passed levels as input, followed by the points gained for each level, and creates the corresponding array of points. Complete the program to calculate and output to the console the sum of all gained points. Sample Input 3 1 4 8 Sample Output 13 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 + points.length + elem + count; //calculate the sum of points //output console.log(sum); }