Fix syntax errors and align with best JavaScript practices.