![]() The spread operator is most commonly used when you want to use the elements of an array as arguments to a function. ![]() ES6 gifted us with the spread operator which looks like ellipses - just three dots in a row. Just separate each element with a comma, like so item1, item2, item3, item4.splice(start, deleteCount, item1, item2, item3, etc.)Īnother concept to keep in mind for this algorithm scripting challenge is the spread operator. Wait a second! What if you don’t want to delete anything? What if you just want to insert elements? That’s fine. splice() at which index to begin deleting elements. splice() several arguments that determine where the deletion begins, how much is deleted, and what is inserted. splice() changes the contents of an array by removing or replacing existing elements and/or adding new elements. So we’re going to need to make a copy of one of them. This will be useful to us in this algorithm scripting challenge because the instructions tell us that we should not directly modify the input arrays. slice() on a string without passing it any additional information, it will return the whole string. slice() extracts a section of a string and returns it as a new string. ![]() That’s good news for us!ĭata Structure: We are going to have to transform our input string into an array in order to manipulate each word separately. The provided test cases also show that we aren’t being thrown any curve balls in terms of weird compound words separated by symbols instead of whitespace. Ultimately, we want to return the input string with the first letter - and only the first letter - of each word capitalized.Įxamples/Test Cases: Our provided test cases show that we should have a capitalized letter only at the beginning of each word. Understanding the Problem: We have one input, a string. ![]() The second array should remain the same after the function runs.The first array should remain the same after the function runs.All elements from the first array should be added to the second array in their original order. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |