Implemented specified changes :

1. Used getElementsByClassName instead of getElementsByTagName.
2. Used classList.add() to add class to a element.
3. replaced case statements with if, else if statements.