Path case a string in JavaScript