This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a new array from the differences between two subject arrays. | |
* | |
* @param {array} filterArr Values found in this array but not the other will form the new array. | |
* @param {array} checkArr filterArr is compared to this array. | |
* @returns {array} Array of values found in filterArr but not checkArr | |
*/ | |
function getDiffArr(filterArr, checkArr) { | |
return filterArr.filter(function (value) { | |
return checkArr.indexOf(value) === -1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("Code Kata - Intermediate - 1 - Sum All Numbers in a Range."); | |
/** | |
* My first attempt. | |
* | |
* Thoughts on this attempt: | |
* | |
* I wasn't satisfied will all the steps | |
* and temporary variables needed for this attempt. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function myCustomFilterIIFE() { | |
"use strict"; | |
angular.module('app') | |
.factory('myCustomFilter', myCustomFilter); | |
myCustomFilter.$inject = []; | |
/** | |
* Setup a custom filter callback. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
"use strict"; | |
angular.module('app') | |
.filter('myFilter', myFilter); | |
myFilter.$inject = []; | |
/** | |
* Used directly in the view in place of 'filter' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function rot13(str) { // LBH QVQ VG! | |
var codeArr = str.split(''); // arrays are fun to work with. | |
var decodes = codeArr.reduce(function (tempArr, currentValue, currentIndex) { | |
var charCode = str.charCodeAt(currentIndex); | |
// Pass through any non-alpha characters. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Clean an array of any duplicate numbers. | |
* | |
* @param {array} arr An array of integers | |
* @returns | |
*/ | |
function removeDuplicateNumbers(arr) { | |
var cleanArr = arr.filter(function filterDupeNumbersFn(number, index, array){ | |
return number !== array[index+1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Clean an array of any duplicate values. | |
* | |
* This would be useful to remove duplicate strings or integers. | |
* It also works for undefined, true, false, null. | |
* It does not work for NaN or objects. | |
* | |
* @param {array} arr An array of any values. | |
* @returns |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Using Reduce - ES6 / ES2015 Version | |
* | |
* The ...destroyThese param is an ES6 rest param; | |
* in this case, it captures all arguments passed in and puts | |
* them into an array called destoryThese. It ignores the | |
* first argument because it is captured in arr. | |
* | |
* @param {array} arr The array to be reduced. | |
* @param {array} ...destoryThese ES6 rest param. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function mutation(arr) { | |
var first = arr[0].toLowerCase().split(''), | |
second = arr[1].toLowerCase().split(''), | |
len = second.length, | |
idx = 0, | |
tempArr = []; | |
while (idx < len) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function chunkArrayInGroups(arr, size) { | |
var newArr = [], | |
len = arr.length, | |
end = size, | |
idx = 0; | |
while (idx < len) { | |
var group = arr.slice(idx, end); |