StringHelpers

String helpers.

Description:
  • String helpers.

Methods

(static) changeToLowerCase(userInput) → {String|undefined}

Change string to lowercase.

Description:
  • Change string to lowercase.

Example
changeToLowerCase(37) => undefined

changeToLowerCase("hello") => hello
 
changeToLowerCase("HeLlo") => hello 

changeToLowerCase("PHANEENDRA KUMAR") => phaneendra kumar

changeToLowerCase() => undefined

changeToLowerCase(null) => undefined
Parameters:
Name Type Description
userInput *

Any string to convert to lowercase

Returns:

Returns string in lowercase, undefined for invalid input

Type
String | undefined

(static) changeToUpperCase(userInput) → {String|undefined}

Change string to uppercase.

Description:
  • Change string to uppercase.

Example
changeToUpperCase("hello") => "HELLO"

changeToUpperCase("HeLlo WorLd") => "HELLO WORLD"

changeToUpperCase("phaneendra kumar") => "PHANEENDRA KUMAR"

changeToUpperCase(37) => undefined

changeToUpperCase(null) => undefined

changeToUpperCase() => undefined
Parameters:
Name Type Description
userInput *

Any string to convert to uppercase

Returns:

Returns string in uppercase, undefined for invalid input

Type
String | undefined

(static) checkStringLength(userInput) → {Number|undefined}

Check string length.

Description:
  • Check string length.

Example
checkStringLength(37) => undefined

checkStringLength("hello") => 5

checkStringLength("phaneendra kumar") => 16

checkStringLength() => undefined

checkStringLength(null) => undefined
Parameters:
Name Type Description
userInput *

Any string to check

Returns:

Returns number if string, undefined if input is null/undefined

Type
Number | undefined

(static) checkTheWord(userInput, userInput2) → {Boolean|undefined}

Check if a word exists within a string.

Description:
  • Check if a word exists within a string.

Example
checkTheWord('Phane kumar', 'Phane') => true

checkTheWord('Phane kumar', 'Kumar') => true

checkTheWord('Phane kumar', 'John') => false

checkTheWord() => undefined

checkTheWord(null, 'Phane') => undefined
Parameters:
Name Type Description
userInput *

The string to search in

userInput2 *

The word to check for

Returns:

Returns true if the word exists, false if not, undefined for invalid input

Type
Boolean | undefined

(static) concateTwoWords(userInput1, userInput2, seperator) → {String|undefined}

Concatenate two strings with a user-defined separator.

Description:
  • Concatenate two strings with a user-defined separator.

Example
concateTwoWords('Phane', 'kumar') => Phane kumar

concateTwoWords() => undefined
 
concateTwoWords("Phaneendra", "Kumar", "+") => Phaneendra+Kumar

concateTwoWords("phaneendra kumar") => undefined

concateTwoWords(null, "Kumar") => undefined
Parameters:
Name Type Description
userInput1 *

First string

userInput2 *

Second string

seperator *

Separator to join the strings (default is a space)

Returns:

Returns concatenated string, undefined for invalid input

Type
String | undefined

(static) removeSpaces(userInput) → {String|undefined}

Remove the spaces from the string.

Description:
  • Remove the spaces from the string.

Example
removeSpaces(37) => undefined

removeSpaces(" hello ") => hello
 
removeSpaces(" phaneendra kumar ") => phaneendra kumar

removeSpaces() => undefined

removeSpaces(null) => undefined
Parameters:
Name Type Description
userInput *

Any string to remove spaces from

Returns:

Returns trimmed string, undefined for invalid input

Type
String | undefined

(static) repeatTheWord(userInput, repeat) → {String|undefined}

Repeat the string a specified number of times.

Description:
  • Repeat the string a specified number of times.

Example
repeatTheWord('Phane', 2) => PhanePhane

repeatTheWord('Phane') => undefined
 
repeatTheWord(" ", 2) => "  "

repeatTheWord("phaneendra kumar") => undefined

repeatTheWord(null, 2) => undefined
Parameters:
Name Type Description
userInput *

The string to repeat

repeat *

Number of times to repeat the string

Returns:

Returns repeated string, undefined for invalid input

Type
String | undefined

(static) replaceAllWords(userInput, findWord, replaceWord) → {String|undefined}

Replace all occurrences of a word in a string with another word.

Description:
  • Replace all occurrences of a word in a string with another word.

Example
replaceAllWords('javascript are so nice and it are very easy', 'are', 'is') => javascript is so nice and it is very easy

replaceAllWords() => undefined
 
replaceAllWords("phaneendra kumar", 'good') => undefined

replaceAllWords("phaneendra kumar", null, 'good') => undefined

replaceAllWords(null) => undefined
Parameters:
Name Type Description
userInput *

Original string

findWord *

Word to find in the string

replaceWord *

Word to replace with

Returns:

Returns replaced string, undefined for invalid input

Type
String | undefined

(static) replaceWord(userInput, findWord, rplword) → {String|undefined}

Replace text with user input.

Description:
  • Replace text with user input.

Example
replaceWord('javascript are so nice', 'are', 'is') => javascript is so nice

replaceWord() => undefined
 
replaceWord("phaneendra kumar", 'good') => undefined

replaceWord("phaneendra kumar", null, 'good') => undefined

replaceWord(null) => undefined
Parameters:
Name Type Description
userInput *

Original string

findWord *

Word to find in the string

rplword *

Word to replace with

Returns:

Returns replaced string, undefined for invalid input

Type
String | undefined

(static) splitTheWord(userInput, seperator) → {Array|undefined}

Split the string by the given separator.

Description:
  • Split the string by the given separator.

Example
splitTheWord('Phane kumar', " ") => ['Phane', 'kumar']

splitTheWord('Phane') => ['Phane']
 
splitTheWord() => undefined

splitTheWord(null, " ") => undefined
Parameters:
Name Type Description
userInput *

The string to split

seperator *

The separator to use (default is a space)

Returns:

Returns an array of substrings, undefined for invalid input

Type
Array | undefined