Creates a function that appends a given character to a string, if (and only if) it does not already end with that character.
var anyString = 'anyString',
stringEndingWithSlash = 'endsWith/',
ensureStringEndsWithSlash = ensureStringEndsWith('/');
ensureStringEndsWithSlash(anyString) === anyString + '/'; // true
ensureStringEndsWithSlash(stringEndingWithSlash) === stringEndingWithSlash; // true