Array.prototype.endsWith = function(arg) {
return this[this.length - 1] === arg ? true : false;
}
const myArray = ['avi', 'itzik', 'yaki'];
console.log(myArray.endsWith('yaki')); // true
console.log(myArray.endsWith('sarah')); // false
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.