Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Working Remotely

Wasiu Idowu Hoxtygen

🎯
Working Remotely
  • Nigeria
View GitHub Profile
View Flutter-Course-Resources.md
View Flutter-Course-Resources.md
View memoization.js
//Basic fibonacci function
function fib(value) {
if (value <= 1) {
return value;
}
return fib(value - 1) + fib(value - 2);
}
View thisConfusion.js
// Object literals
let myObjectLiteral = {
variableKey: "variableValue",
functionKey: function (params) {
// magic goes in here
},
};
// module defined with object literal
View queue.js
function Queue() {
let items = [];
this.enqueue = function (element) {
items.push(element);
};
this.dequeue = function () {
items.shift();
};
this.front = function () {
return items[0];
@Hoxtygen
Hoxtygen / mixed-number-converter.js
Created Dec 27, 2019 — forked from KimSarabia/mixed-number-converter.js
Simple fraction to mixed number converter
View mixed-number-converter.js
// https://www.codewars.com/kata/simple-fraction-to-mixed-number-converter/
var greatest = (a,b) => (b===0) ? a : greatest(b,a%b)
function mixedFraction(s){
arr = s.split('/')
dividend = Number(arr[0])
divisor = Number(arr[1])
if(divisor === 0){
throw "ZeroDivisionError";
} else {
if(dividend%divisor === 0){
@Hoxtygen
Hoxtygen / Diff 2 Arrays
Created Apr 21, 2017
FCC Intermediate Algorithm Scripting
View Diff 2 Arrays
function diffArray(arr1, arr2) {
//create a placeholder array that will contain the resultant values
var newArray = [];
//iterate through arr1
for (var i = 0; i < arr1.length; i++) {
//if arr2 doesn't contain items in arr1
if (arr2.indexOf(arr1[i]) === -1) {
//save it in newArray
newArray.push(arr1[i]);
}
@Hoxtygen
Hoxtygen / forismatic
Created Dec 30, 2016
how to implement forismatic api
View forismatic
$(document).ready(function() {
var quote;
var author;
function getNewQuote() {
$.ajax({
url: "http://api.forismatic.com/api/1.0/",
View Where Do I Belong
function getIndexToIns(arr, num) {
//Add the value of num to the array
arr.push(num);
//Sort the array
arr.sort(function(a, b) {
return a-b;
});
//Get the index of value num
arr = arr.indexOf(num);
return arr;
View Seek and Destroy
function destroyer(arr) {
//create a temporary array that includes both the arrays and the arguments, giving a multidimensional array.
var args = Array.prototype.slice.call(arguments);
//cut out the original array by splicing it out leaving only the arguments
args.splice(0,1);
//create an empty array that will contain the result after the array and arguments have been compared
var newArr= [];
//iterate through the original array
for (var i = 0; i < arr.length; i++) {
//iterate through the arguments array