This file contains hidden or 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
// Implement an exclusive OR function called `preferredName` that has the following interface: | |
var FirstName, | |
LastName; | |
preferredName(FirstName, LastName); | |
// -> false | |
FirstName = 'Hank'; |
This file contains hidden or 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
// Given the following data structure | |
// implement a oldestLivingFather method | |
// that will return the name of the oldest | |
// living father. | |
var people = [ | |
{ | |
name: 'Hank', | |
age: 29, | |
father: 'Don' |
This file contains hidden or 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
//------------------------------------------------------------------- | |
// ** Recursive Solution ** | |
var numbers = [1,2,3,4,5,6,7]; | |
var recursiveRotateArray = function (numberSet,k,n) { | |
counter = k; | |
sizeOfArray = n; | |
if(counter > 0){ |
This file contains hidden or 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 a Memoize-like approach | |
//Loop through multiplying intergers before each index for each position in the array. | |
//Then loop through backwards multiplying intergers after each index for each position. TADA! | |
var get_product_of_all_ints_except_index = function(arrayOfInt){ | |
productsOfAllIntegers = [1,1,1,1,1]; | |
//There is no way in JS to instantiate an array | |
//of a specific size and with specific values other than looping through. | |
//This is to help solve the zero or an array of size 1 edge cases. | |
var product = 1; |