advanced
Identify and Fix Code Bug
Analyze a JavaScript snippet to find syntax or logical errors.
📝 Contenido del prompt
Analyze the following JavaScript code snippet intended to filter out even numbers from an array. Identify why it is not working as expected, explain the error, and provide the corrected code. Code: const nums = [1, 2, 3, 4, 5]; const evens = nums.filter(x => x % 2 == 1);