This week on the code challenge we shall delve further into the important basics with String Manipulation challenges.
Manipulating Strings are an integral part of app development and is applied in numerous cases from modifying user input data to making UX and UI decisions on a page depending on specific user inputs.
In this challenge, we’ll be solving five problems with possibly increased difficulty from first to last.
The five problems are:
In this challenge, an array is provided and stored in a variable, create a function which evaluates the strings in the array by adding a preceding 0 to single numbers (6 => 06, 5 => 05). Double figures remain as is.
Convert a given sentence from camel case to title case. Create a function which evaluates a given sentence argument in camel case and converts it to title case.
This the opposite of the last challenge, create a function which receives a string in title case as an argument and returns a converted version in camel case. Convert the given variable into a sentence with pairs of words in camel case. In cases where the word count is odd, leave the last word standing singularly.
This is a feature utilized by most blogs to calculate reading time. Create a function which calculates the time to read a text in seconds, if it takes over 60 seconds to read a passage return the time to minutes.
Quite an interesting challenge, convert any given word to Pig Latin. Create a function which receives an argument of a string and subsequently returns the Pig Latin version of it. Here’s how to convert words to Pig Latin:
- In words that begin with consonant sounds, all letters before the initial vowel are placed at the end of the word sequence. Then, “ay” is added.
- When words begin with consonant clusters (multiple consonants that form one sound), the whole consonants before the vowel is added at the end followed by an “ay”.
- In words that begin with vowel sounds, one just adds “ay” to the end.
Note that you can write your results to the DOM or even log to console, whichever is fine by you.
Feel free to utilize any method, technique, tool or technology to complete this challenge. A key requirement of these challenges is to be able to correctly evaluate the conditions of the challenge by passing a value as an argument, to the created function.
Goals for the Challenge
On completion of this challenge, you should be able to:
- Solve simple algorithms by manipulating String values.
As a bonus for this challenge, write all functions using ES6 syntax. This should be hella fun!!
In order to get started quickly with this challenge, a base codepen is provided containing empty function definitions. Sample variables with which you can test your functions are also provided. Also, find instructions for each individual challenge in the pen.
Fork this base codepen to get started.
On completion of the challenge, you can showcase your work to receive reviews. Here’s how:
- Post it on Twitter using the hashtag #scotchchallenge and be sure to tag us to see it!
- Build your writing skills by writing about how you solved it and we’ll be glad to feature it in our community posts!
- Post it in the comment section under this post.
- Join the chatter on Spectrum and showcase your solution.
Join the conversation, meet awesome developers, ask questions, discuss awesome topics and leave your feedback in the Scotch Spectrum Forum.
The solution to the post will be released on Friday. Happy coding!!