I am trying to add a Library function for sorting Items in an array. Though I got link and way, but when trying to make a library function, this doesn't work. can someone help me out as it is responding undefined as result.
var arr1 = [5, 4, 2, 6, 9, 2, 8, 1, 6];
Array.prototype.sortItems = function(){
this.sort((a,b) => a - b);
}
console.log(arr1.sortItems());
Reference:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
loga result withoutreturnfrom your function?