forEach Does Not Collect
forEach Does Not Collect
forEach always returns undefined. It can run work for each item, but it will not collect callback return values into an array.
This bug appears when code logs the right values during debugging, then the caller receives nothing useful. The fix is to keep the side effect explicit and return the value that the outer function is responsible for.
Your task: Fix buildAuditTrail so it returns an array of audit messages. Keep the message order the same as the event order.
Free with a JS Exercises account
Sign in to start coding, run your solution, and keep your progress saved for later. No payment needed.
By continuing, you agree to our Terms and Privacy Policy. We'll send occasional product updates and news. You can unsubscribe anytime.
forEach Does Not Collect
forEach always returns undefined. It can run work for each item, but it will not collect callback return values into an array.
This bug appears when code logs the right values during debugging, then the caller receives nothing useful. The fix is to keep the side effect explicit and return the value that the outer function is responsible for.
Your task: Fix buildAuditTrail so it returns an array of audit messages. Keep the message order the same as the event order.