Small refactoring in a exam.js file