Instantly share code, notes, and snippets.

👋

# Huy Lam commanderh

👋
• Data Connecxion
• Houston, TX
Created February 23, 2021 23:57
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
 /*********************************************************************** Write a recursive function called `sort` that takes an array of integers, `nums` and returns an array containing those integers sorted from least to greatest. Your function should accept a default argument called `sorted` which holds the currently sorted elements. Each recursive step should add the smallest number in the `nums` array to the end of `sorted`. There are many ways to accomplish this task but here's a simple algorithm:
Created February 23, 2021 23:56
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
 /*********************************************************************** Write a recursive solution called `isSorted` to determine if the input array is sorted in ascending order. Examples: isSorted([1, 2, 3, 4, 5]); // true isSorted([1, 2, 4, 3, 5]); // false isSorted([2, 4, 6, 7, 8]); // true isSorted([5, 4, 3, 2, 1]); // false
Last active February 23, 2021 23:57
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
 /*********************************************************************** Write a recursive function called `flatten` that takes a single array with any number of nested arrays and returns and array with all the nested contents on one level. Examples: flatten([]); // [] flatten([1, 2]); // [1, 2] flatten([1, [2, [3]]]); // [1, 2, 3]
Created February 23, 2021 03:00
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
 /*********************************************************************** Write a recursive function `iceCreamShop(flavors, favorite)` that takes in an array of ice cream flavors available at the ice cream shop, as well as the user's favorite ice cream flavor. Recursively find out whether or not the shop offers their favorite flavor. Examples: iceCreamShop(['vanilla', 'strawberry'], 'blue moon'); // false iceCreamShop(['pistachio', 'green tea', 'chocolate', 'mint chip'], 'green tea'); // true iceCreamShop(['cookies n cream', 'blue moon', 'superman', 'honey lavender', 'sea salt caramel'], 'pistachio'); // false
Created February 23, 2021 02:49
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
 /*********************************************************************** Write a recursive function `iceCreamShop(flavors, favorite)` that takes in an array of ice cream flavors available at the ice cream shop, as well as the user's favorite ice cream flavor. Recursively find out whether or not the shop offers their favorite flavor. Examples: iceCreamShop(['vanilla', 'strawberry'], 'blue moon'); // false iceCreamShop(['pistachio', 'green tea', 'chocolate', 'mint chip'], 'green tea'); // true iceCreamShop(['cookies n cream', 'blue moon', 'superman', 'honey lavender', 'sea salt caramel'], 'pistachio'); // false