var testStr = "sometext-20202"
var splitStr = testStr.substring(testStr.indexOf('-') + 1);
// function you can use:
function getSecondPart(str) {
return str.split('-')[1];
}
// use the function:
alert(getSecondPart("sometext-20202"));
const str = 'sometext-20202';
const slug = str.split('-').pop();