By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
The function below is supposed to count how many times each word appears in a sentence. But it has three bugs — find them all and fix them.
Approach: trace through the code manually with 'hello hello'. What does each line actually produce?
Fix the bug in the editor on the right, then click "Submit Fix" to have nexGen Tutor evaluate your solution.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.