JSFiddle - React, Tailwind, and code Playground
JavaScript
// your object
var o = {
"numbers": [
{"id":"11111"},
{"id":"22222"}
],
"letters": [
{"id":"aaaaa"},
{"id":"bbbbb"},
{"id":"33333"}
]
};
// gets the index
// a = the array to look in
// p = the property to check
// v = the value to check
function getIndex(a, p, v) {
for(var i=0; i < a.length; i++) {
if(a[i][p] == v) {
return i;
}
}
}
// get the index from the letters array with property 'id' with value '33333'
var index = getIndex(o['letters'], 'id', '33333');
console.log(index);
// if you found the item
if (index !== undefined) {
// get the actual item from the array
var item = o['letters'][index];
console.log(o['letters']);
console.log(o['numbers']);
console.log(item);
// add the item to the other numbers array
o['numbers'].push(item);
// remove the item from the letters array
o['letters'].splice(index, 1);
console.log(o['letters']);
console.log(o['numbers']);
} else {
console.log('did not find the item');
}