Count Characters

Count the number of characters in a string, with option to exclude spaces.

Code

General
includeSpaces ? str.length : str.replace(/\s/g, '').length;

Parameters

The string to count characters in

Whether to include spaces in the count

Browser·fetch() may be limited by CORS

More JavaScript Snippets