Skip to content

Instantly share code, notes, and snippets.

View dillansimmons's full-sized avatar

Dillan Simmons dillansimmons

View GitHub Profile
@dillansimmons
dillansimmons / filterOutDuplicatesArray.js
Last active October 18, 2016 18:19
Filter out duplicates from array and create new array.
// Array
var x = ['x','x','y','q','x'];
var list_no_dupes = function(ogArray) {
// Filter and return new array
var newArray = ogArray.filter(function(ele, pos) {
return ogArray.indexOf(ele) === pos;
});
return newArray;
};
@dillansimmons
dillansimmons / JQueryEqualHeight.js
Last active October 19, 2016 16:19
JQueryEqualHeight
// Equal height function (finds tallest of all and matches) takes class/id/html-element
var equal_height = function equalheight(element) {
maxheight=0;
// Find Tallest of elements
$(element).each(function(){
maxheight = $(this).height() > maxheight ? $(this).height() : maxheight;
})
// Make all elements the same height.
$(element).height(maxheight);
};
@dillansimmons
dillansimmons / findDupesInSingleArray.js
Last active October 18, 2016 18:21
Find duplicates in single array
//Array
var y = ["?","X","Z","Q","W","W"];
/*OPTION ONE*/
var find_dupe = function (array) {
/* Map Arrays, make uppercase if wanted
var yy = array.map(function(x){ return x.toUpperCase() })*/
// Sort function
var sorted_arr = array.slice().sort(); // We use slice to clone the array so the original array won't be modified)
var results = [];
@dillansimmons
dillansimmons / findDupesInArray.js
Last active October 18, 2016 18:08
Map and find duplicates in 2 arrays
// Arrays
var x = ["7","?","X","X","Q", "?"];
var y = ["?","X","Z","Q", "?", "?"];
var find_dupes = function (array1, array2) {
/* Map Arrays, make uppercase if neccessary
var xx = array1.map(function(x){ return x.toUpperCase() })
var yy = array2.map(function(x){ return x.toUpperCase() }) */