function trim(str) { const reg = new RegExp(" ", "g"); const a = str.replace(reg, ""); console.log(a); } s = " 123543"; trim(s);