check it out on npm
!
Features
String.prototype.upperFirst( )
A function that uppercases the first character of string.
- Example Input:
i want this capitalized.
- Expected Output:
I want this capitalized.
String.prototype.lowerFirst( )
A function that lowercases the first character of string.
- Example Input:
I like lowercase
- Expected Output:
i like lowercase
String.prototype.upperWord( )
A function that uppercases the first letter of each word in a string.
- Example Input:
I like caps.
- Expected Output:
I Like Caps.
String.prototype.upperWiggle( )
A function that uppercases every other letter.
- Example Input:
I feel All wiggly.
- Expected Output:
I FeEl aLl wIgGlY.
String.prototype.removeSpaces( )
A function that removes all whitespace from a given string.
- Example Input:
try to decode this!
- Expected Output:
trytodecodethis!
String.prototype.trimSpaces( )
A function that removes only the extra whitespace from a given string (example: “ a b ” → “a b”
).
- Example Input:
far out
- Expected Output:
far out
String.prototype.allCaps( )
A function that makes all characters uppercase. (this is the same as .toUppercase()
).
- Example Input:
i like to yell!!
- Expected Output:
I LIKE TO YELL!!
String.prototype.kababCase( )
A function that removes extra spaces and replaces spaces with the hyphen "-", and makes all characters lowercase.
- Example Input:
What is kabab-case anyway
- Expected Output:
what-is-kabab-case-anyway
String.prototype.snakeCase( )
Removes extra space and replaces spaces with an underscore "_", and makes all characters lowercase.
- Example Input:
Snakes are Amazing
- Expected Output:
snakes_are_amazing
String.prototype.camelCase( )
Lowercases the first character of the first word. Then uppercases the first character of all other words, and removes all spaces.
- Example Input:
CAMELS are a special sort of animal.
- Expected Output:
camelsAreASpecialSortOfAnimal
See Homework 1
Usage
Just connect any of those functions to a string and see magic! Note, none of these functions take in a parameter. They are methods.
Example:
let superString = 'wow! this project is soooooooooooo cool. Just amazing. '
console.log(superString.snakeCase())