Which fix removes the bug?
const nums = [1, 2, 3]; const doubled = nums.forEach((n) => n * 2); console.log(doubled);
- Use
mapinstead - Add a return statement
- Wrap it in
Array.from - Declare
doubledwith let
forEach always returns undefined; map is what collects the results.