function lengthWithoutSpaces(str) {
// Remove all spaces using a regular expression
const stringWithoutSpaces = str.replace(/\s+/g, '');
return stringWithoutSpaces.length;
}
const str = "Node.js is a JavaScript runtime built on Chrome V8";
const length = lengthWithoutSpaces(str);
console.log(length);
/*
run:
42
*/