input string
number of grapheme clusters to remove
output string
var out = removeLast( 'last man standing', 1 );
// returns 'last man standin'
var out = removeLast( 'presidential election', 1 );
// returns 'presidential electio'
var out = removeLast( 'JavaScript', 1 );
// returns 'JavaScrip'
var out = removeLast( 'Hidden Treasures', 1 );
// returns 'Hidden Treasure'
var out = removeLast( '🐶🐮🐷🐰🐸', 2 );
// returns '🐶🐮🐷'
var out = removeLast( 'foo bar', 5 );
// returns 'fo'
Removes the last
n
grapheme clusters (i.e., user-perceived characters) of a string.