Write a program to sum values of given array.



Write a program to sum values of given array...

Answer / Sandhya Yadav

In JavaScript, you can use the reduce() method to add all elements in an array. Example: const arr = [1, 2, 3]; console.log(arr.reduce((accumulator, currentValue) => accumulator + currentValue));

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Data Structures Interview Questions

What is complexity of quicksort?

1 Answers  


How do you do a mergesort?

1 Answers  


Write a code for dynamic allocation of array.

1 Answers   iNautix,


Why do we need algorithm?

1 Answers  


How do you reference all the elements in a one-dimension array?

1 Answers  


Describe full binary tree and complete binary tree.

1 Answers  


How do you sort an array by value?

1 Answers  


Tell me how to find middle element of linked list in one pass?

1 Answers  


How many links are there in a binary tree of N nodes?

1 Answers   Tech Mahindra,


Explain the term recursive case?

1 Answers  


Who invented data structure?

1 Answers  


Write a Program for Reverse a linked list.

1 Answers  


Categories