Slices or arrays in golang

I need help trying to understand arrays and slices in golang. I have two questions from codewars. Could I get help solving them.

You get an array of numbers, return the sum of all of the positives ones.
Example [1,-4,7,12] => 1 + 7 + 12 = 20

Complete the squareSum method so that it squares each number passed into it and then sums the results together.
For example:
squareSum([1, 2, 2]); // should return 9

if anyone can help that would be awesome!

You should try the Go Tour to learn the language basics, it’s quite nice. For your specific question, I think this covers the required topics directly:

Hey @x5tevex,

I’ve annotated some code for both of your questions to help you learn and understand how both functions can be written, but normally it would be preferable to actually read some resources like Jakob posted above and learn by doing by trying to solve the questions, so I would suggest first giving it a go and only then if you still have trouble, check out the answers here:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.