1. Create a function called "findAll" that accepts two strings as parameters: the first string can be any length, the second will be a single character. The function should return an array containing all indices of that character in the string. Return an empty array if the character is not found.
ex: findAll("Hello world", "l") // returns [2,3,9]
findAll("Hello world", "a") // returns []
2. Create a function called "hamming" that returns the Hamming distance between two binary strings. A binary string contains only 0's and 1's, and the Hamming distance between two such strings is the total number of differences between the strings. You may assume that the strings passed to this function will be the same length.
ex: hamming("0000", "0010") // returns 1
hamming("01010", "10101") // returns 5
hamming("000", "000") // returns 0
3. Create a function called "lexi" that accepts a string as a parameter and returns a string with the same characters in alphabetical order. You may assume that the string passed will contain only the letters a-z, with no whitespace or other characters.
ex: lexi("hello") // returns "ehllo"
lexi("alphabet") // returns "aabehlpt"
4. Create a function called "fill" that accepts an array as a parameter. This array will contain two distinct integers (whole numbers), with the smaller number first. The function should return an array of all integers between and including the numbers within the passed array.
ex: fill([3,10]) // returns [3,4,5,6,7,8,9,10]
fill([-4,2]) // returns [-4,-3,-2,-1,0,1,2]
5. Create a function called "factorial" that accepts a positive whole number and returns its factorial. The factorial of a number N is the product of all numbers between 1 and N, and is denoted N!. For instance, 5! = 5x4x3x2x1 = 120. You may assume that the whole number passed is less than 101.
ex: factorial(5) // returns 120
factorial(2) // returns 2
factorial(4) // returns 24
6. Create a function called "month" that accepts a string representing a date with format "mm/dd/yyyy". The function should return a string with the full name of the month included in the date. It is possible to do this using the Date object, but is not required.
ex: month("09/14/2011") // returns "September"
month("02/03/1988") // returns "February"
7. Create a function called "future" that accepts an array containing strings representing dates, formatted as "mm/dd/yyyy". The function should return an array of strings representing dates in the same format, but including the dates that have not already passed. You will need to use the Date object to complete this function.
ex: future(["09/14/2011", "11/23/1987", "06/14/2018", "12/18/2046"]) // returns ["06/14/2018", "12/18/2046"]
future(["09/14/2011", "11/23/1987", "05/13/2016", "12/18/1906"]) // returns []
8. Create a function called "nProps" that accepts an object and returns the number of properties (including methods) of that object.
ex: nProps( { name: 'Damien', age: 11, color: 'white', type: 'dog' }) // returns 4
nProps( { date: '05/10/18', time: '0800', significance: 'final exam'}) // returns 3
9. Create an object constructor called 'circle' that accepts a single parameter, a number representing the radius of a circle. The object returned should have a property called 'r' with the passed number as its value. There should also be a property called 'area' that is calculated to be the area of a circle with that radius. Finally, there should be a property called 'circumference' that is calculated to be the circumference of a circle with that radius. The formula for the area of a circle with radius r, in JavaScript, would be Math.PI*r*r. The circumference would be 2*Math.PI*r.
ex: new circle(4) // returns { r: 4, area: 50.2654824574, circumference: 25.1327412287}
new circle(3) // returns { r: 3, area: 28.2743338823, circumference: 18.8495559215}
10. Write a function called "sumTriples" that accepts a positive whole number as a parameter and returns the sum of all positive multiples of 3 less than or equal to that number. For instance, sumTriples(10) would return the sum 3+6+9 = 18. You may assume that the number passed to the function is less than 1000.
ex: sumTriples(650) // returns 70308
sumTriples(833) // returns 115509
11. Suppose you have an HTML file with the section as below. Create an event listener and handler that detects a change in the select menu with an id of "colors", and sets the background color of the page accordingly.