Cleaned up JS code

Changed the if/else statements to case.