Extend the native JavaScript string class to extend its string manipulation features.
This method evaluates to true if the input string has vowels and false if it does not.
'No vowels'.hasVowels() would yield true
This Method returns the input string in upper case.
'lowercase'.toUpper() would yield LOWERCASE
This Method returns an input string in lower case.
'UPPERCASE'.toLower() would yield uppercase
This Method returns the input string with the first letter in upper case.
'titlecase'.ucFirst() would yield Titlecase
This Method returns true or false depending on whether the input string is a question.
'This is not a question.'.isQuestion() would yield false
This Method returns an array with the words in the input string.
'A rose by any other name.'.words() would yield ['A','rose','by','any','other','name']
This Method returns a count of the number of words in a string.
'A rose by any other name.'.wordCount() would yield 6
This Method returns an array with the words in the input string filtering out any symbols.
'A?rose;by!any|other_name.'.cleanWords() would yield ['A','rose','by','any','other','name']
This Method returns a currency representation of the input string.
'12345.11'.toCurrency() would yield `12,345.11`
This Method returns a number representation of the input currency string.
'12,345.11'.fromCurrency() would yield 12345.11
This Method evaluates to true if the input string is an even digit and false if it is not.
'1234'.isEven() would yield true
This Method returns the input string in title case
'The rain falls mainly in the plains'.toTitle() would yield The Rain Falls Mainly In The Plains
This Method returns the input string in camel case.
'for variables'.toCamel() would yield forVariables
This Method returns the input string in toggle case.
'Gear Shift'.toToggle() would yield gEaR sHiFt
- Clone this repository with the command:
git clone https://github.com/andela-emabishi/string-class.git
- Install [node.js v6.2.2] (https://nodejs.org/en/) on your machine.
- Start up a terminal instance and run the command
npm install
at the root project folder. This will install all the project dependencies. - Start up a terminal instance and run the command
node
. - Type
require ('./src/string-class.js')
into the terminal to have access to the source file. - Use the methods as above in the Functionality section.
- Type
.exit
to exit the node environment.
- Change directory into the root of the repository i.e
string-class
and run the commandnpm install
. This will install all the dependencies needed for the project to run. Run the commandnpm test
. This will run the tests and generate an istanbul test coverage report which can also be accessed through the pathcoverage/lcov-report/index.html
.
This project was created under a GNU Public License. See [here] (https://github.com/andela-emabishi/string-class/blob/dev/LICENSE) for more information.
You can find the author [@emabishi] (https://github.com/emabishi) or [@andela-emabishi] (https://github.com/andela-emabishi) on github and @emabishi on twitter.