JavaScript today was long. Providing a string with the first letter of each word capitalized took way too long for me to do. I ended up looking for a hint on the page. Problem is, the hint just gives the answer so I’m still a bit confused on how to do the problem. I watched a few videos for help. The slice and splice problem was a bit easier.
I started up on finishing Dracula. I started reading it a while ago but hadn’t finished it. So I thought I would continue to read the book. By modern standards, this novel is teetering on the edge of being too repetitive and wordy to be considered “tightly plotted” or “well-paced.” Still, none of us choose to read a book written over a century ago because we’re in search of something that conforms to modern writing conventions. There’s a lot of monologues.
It has been raining all day again. I love this weather. Especially if I don’t have to be out in it. It’s just calming and relaxing.
Yesterday I cleaned up my beauty supplies and got rid of the empties and found some items that I forgot I had. I have so much skin care that I had to clean it up to see what I have. I may be into skin care too much. I like that my drawer is clean now. I also filled up my pill box so I don’t have to get out a pill from each individual bottle. My laundry is also cleaned and put away.
Today I plan to clean the top of my dresser. I need the step stool for that. Yes, my dresser is a bit tall and I can’t reach every surface of the top of the dresser. And one day I will tackle my sock drawer.
JavaScript notes…
————————————————–
Return the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case.
For the purpose of this exercise, you should also capitalize connecting words like the and of.
function titleCase(str) { var arr = str.split(' '); var newStr = ''; for (var i = 0; i < arr.length; i++) { var lower = arr[i].toLowerCase(); newStr += lower.charAt(0).toUpperCase() + lower.slice(1) + ' '; } return newStr.trim(); } console.log(titleCase("I'm a little tea pot"));
You are given two arrays and an index.
Copy each element of the first array into the second array, in order.
Begin inserting elements at index n of the second array.
Return the resulting array. The input arrays should remain the same after the function runs.
function frankenSplice(arr1, arr2, n) { let result = []; result.push(...arr2.slice(0, n)); result.push(...arr1); result.push(...arr2.slice(n, arr2.length)); return result; } console.log(frankenSplice([1, 2, 3], [4, 5, 6], 1));