Intermediate
Debug a JavaScript Error
Identify and fix a common JavaScript reference error.
📝 Nội dung Prompt
Analyze the following JavaScript code snippet which is throwing a 'ReferenceError: variable is not defined'. Identify the cause of the error and provide the corrected code. Ensure the variable is properly scoped within the function.