Skip to content

Instantly share code, notes, and snippets.

Avatar
🏆
React Ninja

Justin® Tellisense

🏆
React Ninja
  • United States
View GitHub Profile
@Tellisense
Tellisense / merge-sort.txt
Last active Oct 31, 2018
Merge Sort JavaScript
View merge-sort.txt
function mergeSort(arr) {
if (arr.length === 1) {
return arr;
}
const center = Math.floor(arr.length / 2);
const left = arr.slice(0, center);
const right = arr.slice(center);
return merge(mergeSort(left), mergeSort(right));
}
@Tellisense
Tellisense / Advanced Array methods: Native javascript code for forEach, map, filter, reduce, every, some
Last active Feb 23, 2021
Creating our own advanced Array methods: forEach, map, filter, reduce, every and some, using native javascript code, so that we can understand them better.
View Advanced Array methods: Native javascript code for forEach, map, filter, reduce, every, some
//forEach
Array.prototype.myforEach = function(cb) {
for (let i = 0; i < this.length; i++){
cb(this[i], i, this);
}
return undefined;
};