View on GitHub

FreeCodeCamp Solutions

Some javascript algorithms

Download this project as a .zip file Download this project as a tar.gz file

js-algorithms

Some basic algorithms implemented in javascript. This code has been produced while doing the @FreeCodeCamp FrontEnd certification.

bouncer.js

Removes all falsy values from an array. Falsy values in JavaScript are false, null, 0, "", undefined, and NaN.

chunk.js

Splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.

confirmEnding.js

Checks if input string ends with given target string.

convertSymbolsToHTML.js

Converts the characters &, <, >, " (double quote), and ' (apostrophe), in a string to their corresponding HTML entities.

convertToRoman.js

Converts decimal numbers to roman numbers.

destroyer.js

Remove all elements from the initial array that are of the same value as the next arguments provided.

diff.js

Returns array with elements that differ.

factorialize.js

Returns the input number factorialized (n!).

findLongestWord.js

Finds longest word in given string.

findMissingLetter.js

Finds missing letter in letter char sequence.

largestNumbersOfSubArrays.js

Find largest number in each of a given array's subarrays.

mutation.js

Returns true if the string in the first element of the array contains all of the letters of the string in the second element of the array.

myReplace.js

Replaces word in string while preserving its case if it's a CamelCase word.

pairDNA.js

Match each molecule to its corresponding one. (A->T, G->C and vice-versa).

palindrome.js

Checks if string is a palindrome in its whole (excludes spaces).

repeat.js

Repeats a given string a given number of times.

reverseString.js

Reverses string

rockPaperScissors.js

Rock, paper, scissors terminal game

rot13.js

Implementation of the ROT13 cypher algorithm.

spinalCase.js

Converts string to spinal-case format.

sumAll.js

Sums all numbers between the two given numbers given as an array.

sumFibs.js

Sums all odd numbers of the fibonacci sequence to a given number, including said number if it's a fibonacci number.

sumPrimes.js

Sums all primes to a given number, including said number if it's prime.

titleCase.js

Returns the provided string with the first letter of each word capitalized.

translate.js

Translates word to pig latin.

truncate.js

Truncates string to given number of characters (including '...' at the end)

unite.js

Merges contents of up to three integer arrays.

where.js

Returns the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted.

whereArtThou.js

Looks through an array of objects (first argument) and returns an array of all objects that have matching property and value pairs (second argument).