- JS primitives
- JS arrays
- JS functions
- Fork and clone this repository
- Create a file in the
js
subdirectory for each solution name the same as the function specified - Write a function for each of the following prompts
- Test your output by running the file with
node
Write a function that returns the length of the longest word in the provided sentence. Make sure not to include any punctuation in your count
Your response should be a number.
e.g.
getLongestWord("over the garden wall.")
// expected output: 6
getLongestWord("I tripped on my own candy trail. Candy Camouflage!")
// expected output: 10
function getLongestWord(str) {
// No, Greg, a-a bird's brain isn't big enough for cognizant speech.
}
write a function that returns the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case.
Bonus for the exclusion of smaller words like "the","of", and "and".
e.g.
titleize("oh, potatoes and molasses!")
// expected output: "Oh, Potatoes And Molasses!"
titleize("hard times at the huskin' bee.")
// Hard Times at the Huskin' Bee.
function titleize(str) {
// if you want some, just ask us!
}
Write a function that takes two arguments, arr
and length
, that splits an array into groups of the specified length and returns them as a two-dimensional array.
If the array length is not evenly divisible by the specified length, the remaining items should still be in their own 2nd dimensional array. e.g.
chunkIt(["potatoes","molasses","greg","wirt"], 2)
// expected output: [["potatoes","molasses"],["greg","wirt"]]
chunkIt(["potatoes","molasses","greg","wirt","beatrice","adelaide","mrs. whispers"], 3)
// expected output: [["potatoes","molasses","greg"],["wirt","beatrice","adelaide"],["mrs. whispers"]]
function chunkIt(arr, length) {
// We're burglars!
}
- All content is licensed under a CC-BY-NC-SA 4.0 license.
- All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].