R
R
Roman2020-04-28 11:03:52
JavaScript
Roman, 2020-04-28 11:03:52

Why does the Uncaught SyntaxError: Unexpected identifier error pop up?

Hello. Do not throw stones, I'm just learning) In general, I'm trying to create a simple function that will find the sum of the array elements. But the browser displays an error on line 1. Here is the code:

Function sumArray(arr) {
  var sum = 0;
  for (var i = 0; i < arr.length; i++) {
    sum += arr[i];
  }
  return sum;
}

let array = [1,2,3,4,5,6,7];
alert(sumArray(array));

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Sarvarov, 2020-04-28
@yagyar001

Function needs to be replaced with function

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question