Input data = '/hello/world/test'
I need output like 'hello-world-test'
in jquery.
I have tried splice,replace method and also a customize condition(sample code below). But still im not able to get the result.
var split_data=data.split('/');
var new_data='';
$.each(split_data,function(x){
if(x!=0){
new_data=split_data[x]+'-'
}
});
console.log("new"+new_data); // Output : hello-world-test-
Here again I have to remove the last hypen in the output string. So is there anyway to accomplish my output.
By the way Im not expert in jquery.