+1 vote
in JavaScript by

Which one of the following options is the correct output for the given code of java script?

var sum=0;  

   

vararr=[101,150,201,30];  

   

arr.forEach(functionmyFunction(element)  

{  

    sumsum=sum+element;  

});  

document.writeln(sum);  



a) 70

b) 75

c) 482

d) error

1 Answer

0 votes
by

Answer: C

Reason: The "forEach()" method used in the above given code is one of the built-in method of JavaScript. This method traverses the whole array just like we use the "for" loop to traverse the array. The term traverse is referred to "going or accessing each element of the array at least one time".

...