HackerEarth
Frontend Engineer
Var Scope in Event Handlers
Medium
ROUND 1debuggingCandidate Not Selected
What will be the output of the following code that attaches click handlers inside a for loop using var? Why does it happen? How would you fix it so that clicking each button correctly prints 0, 1, and 2?
This question was asked in
HackerEarth Frontend Engineer Interview Experience
The HackerEarth interview process involved a single round and covered a broad range of topics related to CSS, JavaScript, and React. Candidates can expect questions focused on event handling, CSS layout properties, and the workings of React hooks and components. Overall, the interview presented a moderate difficulty level, challenging candidates to demonstrate both their technical knowledge and practical coding skills.