├── .gitattributes ├── .github └── FUNDING.yml ├── .gitignore ├── WhereDoIBelong.js ├── caesarsCipher.js ├── checkForPalindromes.js ├── chunkyMonkey ├── README.md └── chunkyMonkey.ts ├── confirmTheEnding.js ├── factorializeANumber.js ├── falcyBouncer.js ├── largestNumInArray.js ├── longestWordInString.js ├── mutations.js ├── repeatString.js ├── reverseString.js ├── seekAndDestroy.js ├── slasherFlick.js ├── titleCaseSentence.js └── truncateString.js /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: CodingTutorials360 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: ['http://paypal.me/dylanisrael'] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /WhereDoIBelong.js: -------------------------------------------------------------------------------- 1 | function where(arr, num) { 2 | // Find my place in this sorted array. 3 | var count = 0; 4 | //Counter variable for results 5 | for (var i = 0; i < arr.length; i++) { 6 | if (arr[i] - num < 0) { 7 | //If arr value - number returns negative it is a smaller number 8 | count = count + 1; 9 | 10 | } 11 | } 12 | return count; 13 | } -------------------------------------------------------------------------------- /caesarsCipher.js: -------------------------------------------------------------------------------- 1 | function rot13(encodedStr) { 2 | var codeArr = encodedStr.split(""); // String to Array 3 | var decodedArr = []; // Your Result goes here 4 | // Only change code below this line 5 | //Create an alphabet character array that goes past Z by 13 letters starting with a 6 | var alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M"]; 7 | //Itterate through inputted string array 8 | for (var i = 0; i < codeArr.length; i++) { 9 | //If current value isn't in alphabet 10 | if (alphabet.indexOf(codeArr[i]) === -1) { 11 | //Add that value to the decodedArr array 12 | decodedArr.push(codeArr[i]); 13 | } else { 14 | //Itterate through alphabet 15 | for (var j = 0; j < alphabet.length; j++) { 16 | //If current vaue in array is equal to alphabet 17 | if (codeArr[i] === alphabet[j]) { 18 | //Add the value to the decodedArr + 13 index shifts in alphabet 19 | decodedArr.push(alphabet[j + 13]); 20 | } 21 | } 22 | 23 | } 24 | } 25 | 26 | // Only change code above this line 27 | return decodedArr.join(""); // Array to String 28 | } -------------------------------------------------------------------------------- /checkForPalindromes.js: -------------------------------------------------------------------------------- 1 | function palindrome(str) { 2 | 3 | str = str.toLowerCase(); 4 | 5 | for (var i = 0; i < str.length; i++) { 6 | str = str.replace(' ', ''); 7 | str = str.replace(',', ''); 8 | str = str.replace('.', ''); 9 | str = str.replace('/', ''); 10 | str = str.replace('_', ''); 11 | str = str.replace('-', ''); 12 | str = str.replace('(', ''); 13 | str = str.replace(')', ''); 14 | } 15 | 16 | var copy = str.split('').reverse().join(''); 17 | 18 | if (copy == str) { 19 | return true; 20 | } else { 21 | return false; 22 | } 23 | } -------------------------------------------------------------------------------- /chunkyMonkey/README.md: -------------------------------------------------------------------------------- 1 | ### Check Out My [YouTube Channel](https://www.YouTube.com/CodingTutorials360) 2 | 3 | ### Check Out More Algorithms like this at FreeCodeCamp 4 | --- 5 | Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array. 6 | 7 | **Example** 8 | - chunkyMonkey(["a", "b", "c", "d"], 2) should return [["a", "b"], ["c", "d"]]. 9 | - chunkyMonkey([0, 1, 2, 3, 4, 5], 4) should return [[0, 1, 2, 3], [4, 5]]. 10 | 11 | **Hints** 12 | - slice() -------------------------------------------------------------------------------- /chunkyMonkey/chunkyMonkey.ts: -------------------------------------------------------------------------------- 1 | function chunkyMonkey(arr: any[], size: number): any[][] { 2 | const nested = []; 3 | let count = 0; 4 | 5 | while (count < arr.length) { 6 | nested.push(arr.slice(count, count += size)); 7 | } 8 | 9 | return nested; 10 | } -------------------------------------------------------------------------------- /confirmTheEnding.js: -------------------------------------------------------------------------------- 1 | function end(str, target) { 2 | var start = str.length - (target.length); 3 | //Var for just comparing end of string; 4 | if (str.substr(start, str.length) == target) { 5 | //Compares end of string with the target string 6 | return true; 7 | } else { 8 | return false; 9 | } 10 | } -------------------------------------------------------------------------------- /factorializeANumber.js: -------------------------------------------------------------------------------- 1 | function factorialize(num) { 2 | var count = num; 3 | 4 | if (count === 0) { 5 | return 1; 6 | } else { 7 | for (var i = 1; i < count; i++) { 8 | num = num * i; 9 | } 10 | } 11 | return num; 12 | } -------------------------------------------------------------------------------- /falcyBouncer.js: -------------------------------------------------------------------------------- 1 | function bouncer(arr) { 2 | // Don't show a false ID to this bouncer. 3 | return arr.filter(Boolean); 4 | } -------------------------------------------------------------------------------- /largestNumInArray.js: -------------------------------------------------------------------------------- 1 | function largestOfFour(arr) { 2 | var largestArray = []; 3 | //Create an empty array to fill later 4 | for (var i = 0; i < arr.length; i++) { 5 | var largestNumber = 0; 6 | //Placeholder to find largets number 7 | for (var j = 0; j < arr.length; j++) { 8 | if (largestNumber < arr[i][j]) { 9 | largestNumber = arr[i][j]; 10 | } 11 | } 12 | largestArray.push(largestNumber); 13 | //Add largest number to new array 14 | } 15 | 16 | return largestArray; 17 | } -------------------------------------------------------------------------------- /longestWordInString.js: -------------------------------------------------------------------------------- 1 | function findLongestWord(str) { 2 | var arrayOfStrings = str.split(" "); 3 | var longestString = ''; 4 | 5 | for (var i = 0; i < arrayOfStrings.length; i++) { 6 | if (longestString.length < arrayOfStrings[i].length) { 7 | longestString = arrayOfStrings[i]; 8 | } 9 | } 10 | str = longestString; 11 | return str.length; 12 | } -------------------------------------------------------------------------------- /mutations.js: -------------------------------------------------------------------------------- 1 | function mutation(arr) { 2 | 3 | var word1 = arr[0].toLowerCase(); 4 | var word2 = arr[1].toLowerCase(); 5 | 6 | for (var i = 0; i < word2.length; i++) { 7 | var value = word1.indexOf(word2[i]); 8 | if (value === -1) { 9 | return false; 10 | } 11 | } 12 | return true; 13 | } -------------------------------------------------------------------------------- /repeatString.js: -------------------------------------------------------------------------------- 1 | function repeat(str, num) { 2 | // repeat after me 3 | var holderArray = []; 4 | for (var i = 0; i < num; i++) { 5 | holderArray.push(str); 6 | } 7 | str = holderArray.join(''); 8 | return str; 9 | } -------------------------------------------------------------------------------- /reverseString.js: -------------------------------------------------------------------------------- 1 | function reverseString(str) { 2 | str = str.split(""); 3 | //Split the string into an array of character for each space of "" 4 | str = str.reverse(); 5 | //Use array function reverse to reverse the values of index first to last and vice versa 6 | str = str.join([separator = '']); 7 | //Reset to a string using array's join funciton and adding the seperator "" 8 | return str; 9 | } 10 | 11 | reverseString("hello"); 12 | 13 | reverseString("Greetings from Earth"); -------------------------------------------------------------------------------- /seekAndDestroy.js: -------------------------------------------------------------------------------- 1 | function destroyer(arr) { 2 | // Remove all the values 3 | var args = Array.prototype.slice.call(arguments); 4 | var filtering = args.splice(0, 1); 5 | return arr.filter(function (element) { 6 | return args.indexOf(element) === -1; 7 | }); 8 | } -------------------------------------------------------------------------------- /slasherFlick.js: -------------------------------------------------------------------------------- 1 | function slasher(arr, howMany) { 2 | // it doesn't always pay to be first 3 | if (howMany < 1) { 4 | return arr; 5 | } else { 6 | arr = arr.splice(howMany, 1); 7 | return arr; 8 | } 9 | } -------------------------------------------------------------------------------- /titleCaseSentence.js: -------------------------------------------------------------------------------- 1 | function titleCase(str) { 2 | var arrayOfStrings = str.split(" "); 3 | //Splits one string into amn array of strings seperated by ' ' 4 | for (var i = 0; i < arrayOfStrings.length; i++) { 5 | var placeHolder = arrayOfStrings[i]; 6 | //Place holder for original string 7 | var upLetter = placeHolder.charAt(0).toUpperCase(); 8 | //Selects first letter and uppercases it 9 | placeHolder = placeHolder.slice(1, placeHolder.length).toLowerCase(); 10 | //Selects 2nd letter to end of the word and lower cases it 11 | arrayOfStrings[i] = upLetter.concat(placeHolder); 12 | //Concats uppercase first letter and rest of lowercase word 13 | } 14 | str = arrayOfStrings.join(' '); 15 | //Takes array and sets str to a signle string 16 | return str; 17 | } -------------------------------------------------------------------------------- /truncateString.js: -------------------------------------------------------------------------------- 1 | function truncateString(str, num) { 2 | if (num > 3) { 3 | if (str.length > num) { 4 | str = str.slice(0, num - 3); 5 | str = str.concat("..."); 6 | } 7 | } else { 8 | str = str.slice(0, num); 9 | str = str.concat("..."); 10 | } 11 | return str; 12 | } 13 | 14 | truncateString("Absolutely Longer", 2); --------------------------------------------------------------------------------