Skip to content

Instantly share code, notes, and snippets.

@sgnl
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save sgnl/79b05d5946019db13429 to your computer and use it in GitHub Desktop.
Save sgnl/79b05d5946019db13429 to your computer and use it in GitHub Desktop.
Recursion
/**
* This function logs to the console each element in an Array of Strings.
* This function accepts an Array of Strings as an argument and returns nothing.
*
* printArray(['Such', 'Hawks', 'Such', 'Hounds']);
*
* Will display in the console as:
* Such
* Hawks
* Such
* Hounds
*/
/**
* This function returns the sum of all the digits up to a given Number,
* and accepts a Number as an argument and returns a Number.
*
* sumTotalUntil(19) //-> 190
* sumTotalUntil(200) //-> 20100
*/
/**
* This function will remove all alphabet characters in a String, leaving only numbers.
* Once all letters are removed, return the string (of Numbers) as an actual
* Number value (do not return it as a String data type).
*
* This function accepts a String as an argument and returns a Number.
*
* parseToNumber("082hufisjdf785klasdju342"); //-> 82785342
*/
/**
* This function returns the smallest value found in an Array.
* This function takes an Array of Numbers as an argument and returns a Number.
*
* minValue([892,372,67,3,26,2]) //-> 2
*/
/**
* This function returns as Array of Strings with a minimal length requirement.
* This function takes an Array of Strings as the first argument and
* also takes a Number as the second argument which servers as the delimiter value.
*
* This function returns an Array of Strings
*
* var dictionary = ["Bush", "Microwave", "Potato Chips", "Doritos", "Par", "Cook"]
*
* normalize(dictionary, 6) //-> [ "Microwave", "Potato Chips", "Doritos" ]
*/
/**
* RECURSION
* "To understand recursion, you must first understand recursion"
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment