Answers for "script map in javascript"

-2

.map in js

// 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'
Posted by: Guest on June-04-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language