substring after a character node js code example
Example 1: javascript substring after character
// function you can use:
function getSecondPart(str) {
return str.split('-')[1];
}
// use the function:
alert(getSecondPart("sometext-20202"));
Example 2: javascript substring after character
const str = 'sometext-20202';
const slug = str.split('-').pop();