Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing report example formatting + unit tests #77

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions stringStuff.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Function to check if a string is empty
export function isEmptyString(str: string): boolean {
return str.trim() === '';
}

// Function to check if a string is a palindrome
export function isPalindrome(str: string): boolean {
const reversedStr = str.split('').reverse().join('');
return str === reversedStr;
}

// Function to count the number of occurrences of a substring in a string
export function countSubstringOccurrences(str: string, substring: string): number {
const regex = new RegExp(substring, 'g');
const matches = str.match(regex);
return matches ? matches.length : 0;
}

// Function to truncate a string to a specified length
export function truncateString(str: string, maxLength: number): string {
if (str.length <= maxLength) {
return str;
}
return str.slice(0, maxLength) + '...';
}

// Function to capitalize the first letter of each word in a string
export function capitalizeWords(str: string): string {
return str.split(' ').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
}