feat: ability to add and view blogs for a user
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
export function countWords(text: string): number {
|
||||
// Trim leading/trailing whitespace, then split on one-or-more whitespace characters
|
||||
const words = text.trim().split(/\s+/);
|
||||
// If the string was empty or only whitespace, split() returns [''], so handle that
|
||||
if (words.length === 1 && words[0] === "") {
|
||||
return 0;
|
||||
}
|
||||
return words.length;
|
||||
}
|
||||
Reference in New Issue
Block a user