JavaScript recursive .find() returns the wrong obj

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;
  }
Answer:1

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 ...

  1. show hide part of text jquery
  2. css-only hide/show part of table
  3. show hide part of div

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....

  1. canvas rotate translate
  2. canvas rotate transform
  3. js canvas rotate translate
  4. canvas scale rotate translate
  5. html canvas translate rotate
  6. javascript canvas translate rotate

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({...

  1. declaring async function javascript
  2. declaring async function
  3. declare async function typescript
  4. declare async function js
  5. declare async function nodejs
  6. declare async function es6
  7. declare async function react
  8. declare async function c#
  9. declare async arrow function
  10. node declare async function
  11. typescript declare async function type
  12. ts declare async function