Title: Bug Biting Back - Help Needed to Fix this Insane JS Loop Issue
"Hey guys, I'm having a brain fart with this JavaScript code that's supposed to loop through a dynamic array of objects and return a filtered list. For some reason, it's hitting an infinite loop and my CPU is crying. Can someone please take a look at the code and help me figure out what's going on?"
```javascript
const data = [
{ id: 1, name: 'John' },
{ id: 2, name: 'Jane' },
{ id: 3, name: 'Bob' }
];
function filterData() {
const result = [];
data.forEach((item) => {
if (/* some condition */) {
result.push(item);
}
});
return result;
}
```
"Hey guys, I'm having a brain fart with this JavaScript code that's supposed to loop through a dynamic array of objects and return a filtered list. For some reason, it's hitting an infinite loop and my CPU is crying. Can someone please take a look at the code and help me figure out what's going on?"
```javascript
const data = [
{ id: 1, name: 'John' },
{ id: 2, name: 'Jane' },
{ id: 3, name: 'Bob' }
];
function filterData() {
const result = [];
data.forEach((item) => {
if (/* some condition */) {
result.push(item);
}
});
return result;
}
```