Inside the code editor we've tried to write a function that takes an array nums as argument and prints to the console the sum of all numbers in that list.
So when we called printSum(Array(1, 2, 3)), we expected our code to print:
6
because 1 + 2 + 3 = 6. But it seems like we made some mistakes because when we run our code, it prints:
1
2
3
Assignment:
Your task is to fix our function such that it correctly computes and prints the desired sum.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check