JSFiddle - React, Tailwind, and code Playground
by Justin
JavaScript
page = '/social-media/location/australia/sdasd';
newPage = prettify(page);
alert(newPage);
function prettify(page) {
pretty = page.substring(1, page.length - 1).replace(/\//g, ' - ').replace('-', ' ').replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
return pretty;
}