UNPKG

@raju0090/string-utilities

Version:

`stringUtils` is a simple utility module that provides functions for common string operations.

29 lines (24 loc) 736 B
// Function to reverse a string function reverse(str) { return str.split('').reverse().join(''); } // Function to convert a string to uppercase function toUpperCase(str) { return str.toUpperCase(); } // Function to convert a string to lowercase function toLowerCase(str) { return str.toLowerCase(); } // Function to check if a string is a palindrome function isPalindrome(str) { const cleanedStr = str.replace(/[^a-zA-Z0-9]/g, '').toLowerCase(); return cleanedStr === reverse(cleanedStr); } // Export the functions to make them available for use in other files module.exports = { reverse, toUpperCase, toLowerCase, isPalindrome, };