0

I have a function that receives an array of objects. The objects are key-value type. The function is for iterating over each array item (object) and diplay its content.

function displayData(myArray) //for debugging
{
    for(var i=0; i<myArray.length;i++)
    {
        console.log(myArray[i]);
    }
}//end displayDay

When I call this function I get this error:

JPM [error]   Message: SyntaxError: missing ) after formal parameters

I checked previous posts that says I must split the array and send it as a string. In this way, I may need to parse the string inside the loop. Is there a simple way to iterate over an array items (objects) in javascript? In arrays, I will set a loop that stops when the length of the array is reached. Can you clarify when shall I stop in a string?

6
  • 3
    is this only a typo: myArray.lenght should be myArray.length Commented May 22, 2017 at 9:17
  • jsbin.com/quxoselawo/1/edit?js,console — I can't reproduce the problem you describe. No error messages are reported. (It doesn't loop over the array because of the type, but that's beside the point). You need to provide a real minimal reproducible example. Commented May 22, 2017 at 9:18
  • "I checked previous posts that says I must split the array and send it as a string." — That doesn't make sense. What previous posts say that? "Splitting" is something you do to strings to turn them into arrays, not the other way around. Commented May 22, 2017 at 9:20
  • @PeterSmith — I can't see any way that would fix the quoted error message. Commented May 22, 2017 at 9:20
  • 1
    @user7945230 — That question is full is nonsense because the problem the OP has is very unclear. This is similar to this question where you have some code, and you've quoted an error message, but running the code doesn't result in that error message. You need to provide a minimal reproducible example. Commented May 22, 2017 at 9:43

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.