I have the following object:
const obj = {
a: 1,
b: 2,
c: 3,
d: 4,
condition: 'checked' // could be "unckecked" or anything else
items: []
}
and I want to check if the condition === checked then I will have to move a and b inside items like this:
const obj = {
c: 3,
d: 4,
condition: 'checked' // could be "unckecked" or anything else
items: [{
a: 1,
b: 2,
}]
}
I have tried splice and tried to loop through the object with for(of) but didn't manage to do it, any idea how?
deleteor create a new object and populate it.[<>]snippet editor.if( obj.condition === 'checked' )and append the values toobj.items?