Test case details

Preparation Code

const currentLabel = "I::think::Ruth's::dog::is::cuter::than::your::dog!"; const searchTerm = '::';

Test cases

Test #1

const splitLabel = currentLabel.split('::'); const lastWord = splitLabel.pop(); // Remove the last element

Test #2

const index = currentLabel.lastIndexOf(searchTerm); const lastWord = index === -1 ? currentLabel : currentLabel.substring(index + 2)