For further actions, you may consider blocking this person and/or reporting abuse
This community will be migrating to a dedicated subforem in the near future. We are excited to announce a new take on the CodeNewbie Community soon! Email support@forem.com if you have any questions.
Hi Shaik,
Well, that error message is more information than we had before - what it says is that the result returned from
constructoris not an array (and might just be a normal object like{}). This is something we can tell, becauseforEachis a method present on arrays, but the variableobjectsdidn't have that function present when it was called. It also says the code you wrote in the function is getting called (the error happened inside your function).You could try to see if you always get just a single object back, by doing something like this:
If that's still failing - it looks from the screenshot like you have a "show console" tab available in addition to the Results - you might try to get a look at the
constructor()'s output by trying this and checking that tab afterward to get a look at what you're trying to modify:It's possible that sometimes you get an array and sometimes you get a plain object, in which case the solution might have to check whether forEach is a function and decide what to do. It's also possible that I don't know any more than you about the problem, and the right answer might be "obvious" to someone who knew javascript better.