Intermediate
Debug a JavaScript Error
Identify and fix a common JavaScript reference error.
📝 प्रॉम्ट सामग्री
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.