Skip to content
Advertisement

how to replace partial content of JS object array

I have a JS object array as :

JavaScript

I’m saving the objects that are (Left) & (Right) to a new array.

JavaScript

What I cannot do is, I’m trying to replace the partial string of the remaining[] array.

in this example , the results are is

JavaScript

what I would like to do / the expected outcome is to have the opposite of the results arr.

JavaScript

Advertisement

Answer

You did everything and just needed the opposite of what is present. Without affecting the original object, you can use the spread operator to store the object, then check what type of content is stored within the parentheses, and alter them:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement