function countWhitespaceCharacters(str: string) {
let count: number = 0;
const length: number = str.length;
for (let i: number = 0; i < length; i++) {
if (/\s/.test(str[i])) {
count++;
}
}
return count;
}
const str: string = "TypeScript \n Programming \r Language \t ";
console.log("Total white spaces: " + countWhitespaceCharacters(str));
/*
run:
"Total white spaces: 10"
*/