×

Multiple-Choice Questions

Web Technologies MCQs

Computer Science Subjects MCQs

Databases MCQs

Programming MCQs

Testing Software MCQs

Digital Marketing Subjects MCQs

Cloud Computing Softwares MCQs

AI/ML Subjects MCQs

Engineering Subjects MCQs

Office Related Programs MCQs

Management MCQs

More

What is the output of the following JavaScript code? | Question 15

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

<script>
	var values = [10, 20, 30, 40];
	
	var result = values.reduceRight(function(x,y){
		return (x + y);
	});
	
	document.write("Result: " + result);
</script>
  1. Result: 40
  2. Result: 70
  3. Result: 90
  4. Result: 100

Answer: D) Result: 100

Explanation:

In the above JavaScript code, we used the reduceRight() method which is used to reduce the given array elements into a single value by executing a reducer function. The reducer() function is applied against the accumulator and reduces all the elements from right to left. Thus, the output would be "Result: 100".

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.