const path = "/api/ld/bca";
const pathPartsArray = path.split("/");
const lastArrayIndex = pathPartsArray.length - 1;
const lastArrayElement = pathPartsArray[lastArrayIndex];
const lastStringIndex = lastArrayElement.length - 1;
let resultString = "";
for (let i = lastStringIndex; i >= 0; i--) {
resultString += lastArrayElement[i];
}
console.log(resultString);