To complete this assessment, create a Github Gist for each tasks below. Once completed, please email a link for each Gist to [email protected].
This assessment was designed to help evaluate your knowledge of the core Javascript language. Please do not use any libraries such as jQuery of Underscore.
-
Create a function called
fizzBuzz
that takes an integer (n). The function should loop over each number between 1 and n and prints "Fizz" if the number is divisible by 3, "Buzz" if the number is divisible by 5, "FizzBuzz" if the number is divisible by 3 and 5, and if the number is not divisible 3 or 5, it should print the number. -
Create a function called
flipCoin
that takes no parameters and randomly returns the string 'heads' or 'tails'. Create a second function calledflipCoinResults
that takes an integer n and runsflipCoin
n times.flipCoinResults
should return a string that represents the distribution of heads and tails for a given request. -
If we list all of the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6, and 9. The sum of these multiples is 23. Create a function called
sumOfMultiples
that replicates this behavior.sumOfMultiples
should take one parameter that represents the maximum number (e.g. 1000). -
Currying allows you to easily create custom functions by partially invoking an existing function. Extend the Function's prototype to add a
.curry
function, and then show an example how.curry
could be used. Keep in mind that even though currying is similar to closures, they are not the same thing. -
Create a function called
highlightArticles
that takes a string as its parameter. An example function call would behighlightArticles("The quick brown fox jumped over the lazy dog")
. In your function, highlight all of the definite and indefinite articles, making the definite articles highlighted in yellow and the indefinite articles highlighted in blue. -
Extra credit: Create a function that takes an array of x and y coordinates. Assuming that the first element in the array is the starting point and the last element in the array is the ending point, return an array of x and y coordinates that represents the shortest possible route one could take to hit every point.