@toluwap/complete-string
v0.0.10
Published
The completeString function is a JavaScript function that ensures a given string ends with a desired ending. If the string already ends with the desired ending, the function returns the original string. Otherwise, the function adds the missing characters
Downloads
31
Readme
Complete String
The completeString function is a JavaScript function that ensures a given string ends with a desired ending. If the string already ends with the desired ending, the function returns the original string. Otherwise, the function adds the missing characters to the end of the string.
import { completeString } from "@toluwap/complete-string"
const result = completeString(inputString, desiredEnding);
The completeString function takes two arguments:
inputString (string): The input string to be checked. desiredEnding (string): The desired ending that the input string should have. The function returns the original string with the desired ending appended, if necessary.
console.log(completeString("https://url.com", "/api/v4")); // output: https://url.com/api/v4
console.log(completeString("https://url.com/api", "/api/v4")); // output: https://url.com/api/v4
console.log(completeString("https://url.com/api/v4", "/api/v4")); // output: https://url.com/api/v4
test
$ npm test