medium
Debug JavaScript Code
Find and fix a logic error.
📝 Contenu du Prompt
Analyze the following JavaScript code snippet. It is intended to reverse a string but is producing an incorrect output. Identify the bug, explain why it is happening, and provide the corrected code.