This is a collection of JavaScript algorithms taught by Brad Traversy in a short series of YouTube videos titled JavaScript Cardio. I like to collect algorithm exercises in case I ever need to do a coding interview, so here are a bunch more.

Most of the algorithms in these videos have multiple solutions; I’ve included some of them in my own notes on the videos. For further examples look at Brad’s repo for the videos, in particular paying attention to the index_extra.js files where students are encouraged to submit their own unique solutions to the algorithms via pull requests.

Here is a list of the algorithms covered in each video. Note that I have written about some of these algorithms elsewhere (for instance, here, here, and here), but it is good to re-visit these algorithms from time to time.

NOTE: I have updated this post after I transferred all the algorithms to Repl.it, adding hyperlinks to each algorithm individually. Still, I suggest looking at Brad’s repo - linked above - for a more comprehensive look at how each of these algorithms can be solved.

  • JavaScript Cardio Session 1
    • reverseString: Return a string in reverse.
    • isPalindrome: Return true if palindrome and false if not. Note that this example uses regular expressions. I have another Repl.it file that does not.
    • reverseInt: Return an integer in reverse
    • capitalizeLetters: Return a string with the first letter of every word capitalized.
    • maxCharacter: Return the character that is most common in a string.
    • fizzBuzz: Write a program that prints all the numbers from 1 to 100. For multiples of 3, instead of the number, print “Fizz”, for multiples of 5 print “Buzz”. For numbers which are multiples of both 3 and 5, print “FizzBuzz”.
  • JavaScript Cardio Session 2
    • longestWord: Return the longest word of a string.
    • chunkArray: Split an array into chunked arrays of a specific length.
    • flattenArray: Take an array of arrays and flatten to a single array.
    • isAnagram: Return true if anagram and false if not.
    • letterChanges: Change every letter of the string to the one that follows it and capitalize the vowels.
  • JavaScript Cardio Session 3
    • addAll: Return a sum of all parameters entered regardless of the amount of numbers - NO ARRAYS.
    • sumAllPrimes: Pass in a number to loop up to and add all of the prime numbers. A prime number is a whole number greater than 1 whose only factors are 1 and itself.
    • seekAndDestroy: Remove from the array whatever is in the following arguments. Return the leftover numbers in an array.
    • sortByHeight: Some people are standing in a row in a park. There are trees between them which cannot be moved. Your task is to rearrange the people by their heights in a non-descending order without moving the trees.
    • missingLetters: Find the missing letter in the passed letter range and return it. If all letters are present, return undefined.
    • evenOddSums: Take in an array and return an array of the sums of even and odd numbers.