Skip to content

Instantly share code, notes, and snippets.

View fortunee's full-sized avatar
🎯
Focusing

Fortune Ekeruo fortunee

🎯
Focusing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am fortunee on github.
  • I am fortunee (https://keybase.io/fortunee) on keybase.
  • I have a public key ASC3YsJqVSRn-c0Zmf-EIWfNmRbamUvNhllvnUNdZeuh2wo

To claim this, I am signing this object:

@fortunee
fortunee / ruleSix.js
Created June 9, 2019 18:46
The sixth rule of javascript this keyword example
// Rule #6 example (arrow functions)
function RuleSix() {
this.value = 'Some value for rule #6';
this.printValue = () => {
console.log('Rule six value >>>>', this.value);
}
}
const ruleSix = new RuleSix();
const printRuleSixVal = ruleSix.printValue;
@fortunee
fortunee / ruleFive.js
Created June 9, 2019 18:44
The fifth rule of javascript this keyword
// Rule #5 example
function RuleFive() {
this.value = 'Some value for rule #5';
this.printValue = function() {
console.log('Rule five value >>>>', this.value);
}
}
const ruleFiveInstance = new RuleFive();
@fortunee
fortunee / ruleFour.js
Created June 9, 2019 18:41
The fourth rule of javascript this keyword example
// Rule #4 example
this.value = 'Some value';
function ruleFour() {
console.log('Rule four value >>>>', this.value);
}
// Refers to the global "this" value
ruleFour();
@fortunee
fortunee / ruleThree.js
Created June 9, 2019 18:39
The third rule of javascript this keyword example
// Rule #3 example
function RuleThree() {
this.value = 'Some value for rule #3';
this.printValue = function() {
console.log('Rule three value >>>>', this.value);
}
}
const ruleThreeInstance = new RuleThree();
const ruleThreePrintValue = ruleThreeInstance.printValue;
@fortunee
fortunee / ruleTwo.js
Created June 9, 2019 18:35
The second rule of javascript this keyword example
// Rule #2 example
function RuleTwo() {
this.value = 'Some value for rule #2';
this.printValue = function() {
console.log('Rule two value >>>>', this.value);
}
}
const ruleTwoInstance = new RuleTwo();
@fortunee
fortunee / ruleOne.js
Last active June 9, 2019 18:34
The first rule of javascript this keyword example
// Rule #1 example
function RuleOne() {
this.value = 'Some value for rule #1';
this.printValue = function() {
console.log('Rule one value >>>>', this.value);
}
}
// using the new keyword here creates a brand new object for "this"
const ruleOneInstance = new RuleOne()
@fortunee
fortunee / breadthFirstSearch.js
Last active May 9, 2019 21:21
Breadth First Search JavaScript implementation
class Node {
constructor(data) {
this.data = data;
this.children = [];
}
}
class Graph {
constructor(root) {
this.root = root;
@fortunee
fortunee / selectionSort.js
Created February 19, 2019 10:44
Selection sort algorithm
const selectionSort = function(array) {
let temp;
for(let i = 0; i < array.length; i++) {
let minIndexVal = i;
for(let j = i + 1; j<array.length; j++) {
if(array[j] < array[minIndexVal]) {
minIndexVal = j;
}
@fortunee
fortunee / insertionSort.js
Last active March 9, 2023 04:17
Insertion Sort: sorting algorithm
/**
* Insertion sort:
* Big O notation of O(n^2) due to the double loop
*/
const insertionSort = (items) => {
/**
* 1. Loop through array of unsorted items
* 2. Grab the value of the current iteration index
* 3. Initialize j index for a second loop back through the sorted section
* 4. Loop back and compare the last item in the sorted section with the