Web Development & Javascript
#100daysofcode

Make a Person
From the FreeCodeCamp intermediate algorithms here: Fill in the object constructor with the following methods below: FreeCodeCamp – Make a Person As with all code there are probably multiple ways to complete this challenge. My feeling is that this solution is quite straightforward, but that perhaps could be just from my own perspective. Somebody elseContinue reading “Make a Person”

Arguments Optional
From the FreeCodeCamp intermediate algorithms here: Create a function that sums two arguments together. If only one argument is provided, then return a function that expects one argument and returns the sum. For example, addTogether(2, 3) should return 5, and addTogether(2) should return a function. Calling this returned function with a single argument will then return the sum: var sumTwoAndContinue reading “Arguments Optional”

Everything Be True
From the FreeCodeCamp intermediate algorithms here: Check if the predicate (second argument) is truthy on all elements of a collection (first argument). In other words, you are given an array collection of objects. The predicate pre will be an object property and you need to return true if its value is truthy. Otherwise, return false. In JavaScript, truthy values are values that translate to true when evaluatedContinue reading “Everything Be True”

Binary Agents
From the FreeCodeCamp intermediate algorithms here: Return an English translated sentence of the passed binary string. The binary string will be space separated. FreeCodeCamp – Binary Agents For this challenge I began by splitting the binary string into an array of the given 8 bit blocks. This would make it a lot easier to workContinue reading “Binary Agents”

Steamroller
From the FreeCodeCamp intermediate algorithms here: Flatten a nested array. You must account for varying levels of nesting. FreeCodeCamp – Steamroller A quick post today about flattening nested arrays down to one array. However a quick google of ‘flatten nested arrays in javascript’ lead me here. … which essentially takes care of this algorithm forContinue reading “Steamroller”

Drop It
From the FreeCodeCamp intermediate algorithms here: Given the array arr, iterate through and remove each element starting from the first element (the 0 index) until the function func returns true when the iterated element is passed through it. Then return the rest of the array once the condition is satisfied, otherwise, arr should be returned as an empty array. FreeCodeCamp – DropContinue reading “Drop It”

Smallest Common Multiple
From the FreeCodeCamp intermediate algorithms here: Find the smallest common multiple of the provided parameters that can be evenly divided by both, as well as by all sequential numbers in the range between these parameters. The range will be an array of two numbers that will not necessarily be in numerical order. For example, ifContinue reading “Smallest Common Multiple”

Sum All Primes
From the FreeCodeCamp intermediate algorithms here: A prime number is a whole number greater than 1 with exactly two divisors: 1 and itself. For example, 2 is a prime number because it is only divisible by 1 and 2. In contrast, 4 is not prime since it is divisible by 1, 2 and 4. Rewrite sumPrimes so it returnsContinue reading “Sum All Primes”

Sum All Odd Fibonacci Numbers
From the FreeCodeCamp intermediate algorithms here: Given a positive integer num, return the sum of all odd Fibonacci numbers that are less than or equal to num. The first two numbers in the Fibonacci sequence are 1 and 1. Every additional number in the sequence is the sum of the two previous numbers. The first six numbersContinue reading “Sum All Odd Fibonacci Numbers”

Convert HTML Entities
From the FreeCodeCamp intermediate algorithms here: Convert the characters &, <, >, ” (double quote), and ‘ (apostrophe), in a string to their corresponding HTML entities. FreeCodeCamp – Convert HTML Elements For this task there will certainly be other ways to complete it. However although the code may look slightly long, it did not take a long time to write out. TheContinue reading “Convert HTML Entities”

Sorted Union
From the FreeCodeCamp intermediate algorithms here: Write a function that takes two or more arrays and returns a new array of unique values in the order of the original provided arrays. In other words, all values present from all arrays should be included in their original order, but with no duplicates in the final array.Continue reading “Sorted Union”

Missing Letters
From the FreeCodeCamp intermediate algorithms here: Find the missing letter in the passed letter range and return it. If all letters are present in a range, return undefined. FreeCodeCamp – Missing Letters There’s not too much to say about this one. One thing which I can note is that JavaScript, as a language, is extremelyContinue reading “Missing Letters”

DNA Pairing
From the FreeCodeCamp intermediate algorithms here: The DNA strand is missing the pairing element. Take each character, get its pair, and return the results as a 2d array. Base pairs are a pair of AT and CG. Match the missing element to the provided character. Return the provided character as the first element in each array.Continue reading “DNA Pairing”

Search & Replace
From the FreeCodeCamp Intermediate Algorithms Challenges, here: Perform a search and replace on the sentence using the arguments provided and return the new sentence. First argument is the sentence to perform the search and replace on. Second argument is the word that you will be replacing (before). Third argument is what you will be replacingContinue reading “Search & Replace”

Pig Latin – ‘igpay atinlay’
From the FreeCodeCamp Intermediate Algorithms Challenges, here: Translate the provided string to pig latin. Pig Latin takes the first consonant (or consonant cluster) of an English word, moves it to the end of the word and suffixes an “ay”. If a word begins with a vowel you just add “way” to the end. If a wordContinue reading “Pig Latin – ‘igpay atinlay’”

Spinal Tap Case – spinal-tap-case
From the FreeCodeCamp Intermediate Algorithms Challenges, here: Convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes. FreeCodeCamp – Spinal Tap Case Let’s turn it up to eleven! This was a great problem to learn more about RegEx and just how powerful it can be… Surely like most others attempting this problem, I began byContinue reading “Spinal Tap Case – spinal-tap-case”

Wherefore Art Thou
From the FreeCodeCamp Intermediate Algorithms Challenges, here: Make a function that looks through an array of objects (first argument) and returns an array of all objects that have matching name and value pairs (second argument). Each name and value pair of the source object has to be present in the object from the collection ifContinue reading “Wherefore Art Thou”

Seek and Destroy
From the FreeCodeCamp Intermediate Algorithms Challenges, here: You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments. Note: You have to use the arguments object. FreeCodeCamp – SeekContinue reading “Seek and Destroy”

Diff Two Arrays
From the FreeCodeCamp Intermediate Algorithms Challenges: Compare two arrays and return a new array with any items only found in one of the two given arrays, but not both. In other words, return the symmetric difference of the two arrays. Note: You can return the array with its elements in any order. FreeCodeCamp – DiffContinue reading “Diff Two Arrays”

Sum All Numbers in a Range
From the FreeCodeCamp Intermediate Algorithms Challenges: We’ll pass you an array of two numbers. Return the sum of those two numbers plus the sum of all the numbers between them. The lowest number will not always come first. For example, sumAll([4,1]) should return 10 because sum of all the numbers between 1 and 4 (both inclusive) is 10. FreeCodeCampContinue reading “Sum All Numbers in a Range”
Follow My Blog
Get new content delivered directly to your inbox.