📅  最后修改于: 2022-03-11 15:02:55.543000             🧑  作者: Mango
// A function which returns the last character of a given string
function returnLast(arr) {
return arr.at(-1);
}
let invoiceRef = 'myinvoice01';
console.log( returnLast(invoiceRef) );
// Logs: '1'
invoiceRef = 'myinvoice02';
console.log( returnLast(invoiceRef) );
// Logs: '2'