function lengthWithoutSpaces(str: string) {
// Remove all spaces using a regular expression
const stringWithoutSpaces: string = str.replace(/\s+/g, '');
return stringWithoutSpaces.length;
}
const str: string = "TypeScript extends JavaScript by adding types to the language";
const len: number = lengthWithoutSpaces(str);
console.log(len);
/*
run:
53
*/