So I’ve been working on a small web-page that allows you to search what car companies own other car companies.
It takes input from the user, checks the input against a JSON formatted array and then appends the “name” and “children” key-value pairs into their appropriate fields in the HTML.
Plnkr public link: http://plnkr.co/edit/17OicY?p=preview
Problem is: When the user submits a second search, the function I’ve created to remove all the previous entries isn’t working properly – it only removes every ~other~ child result and I don’t know why.
- Search “fiat”
- Search “ford”
- Result is: Only half of fiat’s children are removed.
I think there’s something wrong with my removeChildren function’s logic, but I’ve been stuck on it for several hours and I just can’t see what’s wrong with it.