Q. What will be the output of the following JavaScript code?

Code:
<script>
	const arr = [10, 20, 30];
	let result = 0;
	
	arr.forEach(myFunction);
	
	document.write("Result: " , result)
	function myFunction(value, index, array) {
	  result += value; 
	}
</script>
  • (A) Result: 60
  • (B) Result: 102030
  • (C) Result: 10,20,30
  • (D) ValueError
πŸ’¬ Discuss
βœ… Correct Answer: (A) Result: 60

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
337
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Ram Sharma
Publisher
πŸ“ˆ
99%
Success Rate