This content originally appeared on DEV Community and was authored by Abu Saleh Faysal
Given an array of integers, find the sum of its elements. For instance, if the array=[10,20,30], then it will return 10+20+30 = 60.
Solution:
Explanation:
- Step 01: Take a variable named sum and store an initial value as 0.
- Step 02: Iterate a for loop through the given array.
- Step 03: Add up each array element in the sum variable.
-Step 04: Return the sum variable after adding all the array element.
This content originally appeared on DEV Community and was authored by Abu Saleh Faysal
Abu Saleh Faysal | Sciencx (2022-04-19T16:06:10+00:00) HackerRank — Problem Solving — JavaScript — Simple Array Sum. Retrieved from https://www.scien.cx/2022/04/19/hackerrank-problem-solving-javascript-simple-array-sum/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.