-1

I have the following code:

usersArray.forEach(user => {
   users.push(data.Users.filter(userAws => userAws.Username === user.username))
 });

this returns Arrays in Arrays.

enter image description here

But I want to add the inner Object direktly to the outher Array.

How can I flatten the inner Array?

thanks

UPDATE

usersArray.forEach(user => {
            users.push([].concat.apply([], data.Users.filter(userAws => userAws.Username === user.username)))
        });
Felix
  • 5,452
  • 12
  • 68
  • 163

1 Answers1

0

solution is this:

users.push(...data.Users.filter(userAws => userAws.Username === user.username))
Felix
  • 5,452
  • 12
  • 68
  • 163