Python Code For String Operations Javascript