If you want to create a hashtag generator in Javascript, then you can do the following:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
function generateHashtag(string) {
  if (string.trim() === '') return false;

  const stringWithCamelCase = string
    .split(' ')
    .map(word => word.charAt(0).toUpperCase() + word.slice(1))
    .join('');

  const stringWithHashtag = `#${stringWithCamelCase.trim()}`;

  return stringWithHashtag.length > 140 ? false : stringWithHashtag;
}

How to use the Hashtag Generator

1
2
3
4
const hashtag = generateHashtag("My New Hashtag !")

console.log(hashtag);
// #MyNewHashtag!