I have a small issue with a recursive .find() . when I use it to find ID === 2, it returns be the object with ID === 1 ...
I have been scratching my head and I don't understand why that happens
my object is similar to this
UPDATE: while debugging, it does seem to finish at the right object, but the final return gives the parent of the right object, not the actual object
{ID: 1,
children: [
{ID:2,
children: [
{ID:4,
children: [...]},
]},
{ID:3,
children: [...]},
]}
findItem(ID: number, items: Agenda[] = this.getItems()){
const foundItem = items.find(a => {
if (ID === a.ID) {
return a;
} else {
return this.findItem(ID, a.children);
}
})
return foundItem;
}
I'm learning JS/Jquery and I'm trying to make a part of a form show and hide when clicking on part of the form. I am able to open part of the form, but not to close it again. As there is no error ...
I'm learning JS/Jquery and I'm trying to make a part of a form show and hide when clicking on part of the form. I am able to open part of the form, but not to close it again. As there is no error ...
I'm trying to correctly orient an image uploaded to a canvas from Apple devices. Here's a sample of my code to correctly orient something with EXIF orientation 6 ctx.rotate(0.5 * Math.PI); ctx....
I'm trying to correctly orient an image uploaded to a canvas from Apple devices. Here's a sample of my code to correctly orient something with EXIF orientation 6 ctx.rotate(0.5 * Math.PI); ctx....
I am trying to convert form data into json I have a html table as following. On form submit what i want to do is convert it to json <form class="sales-order-form"> <table class="table"&...
I am trying to convert form data into json I have a html table as following. On form submit what i want to do is convert it to json <form class="sales-order-form"> <table class="table"&...
Here is what I have already: myFunct({ myObj: { db } }) I need to add another function in such as: myFunct({ myObj: async ({ req }) => { //more scripts } }) What I tried and failed: myFunct({...
Here is what I have already: myFunct({ myObj: { db } }) I need to add another function in such as: myFunct({ myObj: async ({ req }) => { //more scripts } }) What I tried and failed: myFunct({...