Refactored index.js 

It's better to use a switch condition instead of making multiple calls to `.replace()`.