Thursday, April 18, 2024
HomeSoftware EngineeringCreate a Hashtag Generator in Javascript

Create a Hashtag Generator in Javascript


If you wish to create a hashtag generator in Javascript, then you are able to do the next:

perform generateHashtag(string) {
  if (string.trim() === '') return false;

  const stringWithCamelCase = string
    .cut up(' ')
    .map(phrase => phrase.charAt(0).toUpperCase() + phrase.slice(1))
    .be a part of('');

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

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

use the Hashtag Generator

const hashtag = generateHashtag("My New Hashtag !")

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

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments