Looking to develop a JavaScript function that checks if the last characters of a string match a given target. The function must utilize the .substr() method for this purpose.
function endOfString(str, target) {
let endCharacters = str.substr(-target.length);
if (endCharacters === target) {
return true;
} else {
return false;
}
}
console.log(endOfString('Bastian', 'n'));