This exercise in my bootcamp is a little tricky. I believe I have the basics but I’d like some feedback. I don’t think I’m using the right for loop. Or I have the array variables setup wrong. I think I’m also adding them wrong.
function sumArray ([arr1], [arr2]) {
for (let arr1 = 0; arr1 > 5; arr1++)
console.log([arr1] + [arr2]);
}
I appreciate you walking me through this. I think it needs two arguments/parameters because it needs to add two. As for the brackets, how else do I tell the program they’re array elements?
Wow, lol. Okay I need to take control of my ADHD and reading carefully otherwise I have 0% chance to make a penny in this career path. My fault and I need to re-read directions.
i think you lack some basics and it will be good idea to check on the FCC JS curriculum. There are many loopholes in your code and your logic.
Regarding the challenge at hand, lets say we have the array arr=[2,5,3,7]. You want to sum all its elements. How would you target the element at the second position? (5: arr[1]). How would you combine the first and second elements? arr[0]+arr[1]. There is also the basic task of creating a loop which iterates throught the elements of an array. The array length would determine how many iterations the loop will have(for array with 5 elements, we loop 5 times, for 7 elements, we loop 7 etc).