JSFiddle - React, Tailwind, and code Playground

JavaScript

var str = 'Una cosa';

alert(str.replace(/\s+/g, '').length);