JSFiddle - React, Tailwind, and code Playground

by hescano

JavaScript

function generateHashtag (str) {
	str = str.replace(/\s{1,}/g, " ");
	return str.length >= 140 || str.trim().length === 0 ? false : "#" + str.replace(/\s{1,}/g, " ").split(" ").map((w) => w[0].toUpperCase() + w.substr(1)).join('');
}


console.log(generateHashtag("                                                                                                                                                                                                                                    "))