• 0

Implement twit box word limiting feature

Problem :

Implement a twitter like twit-box component which limits the feed to 140 characters.

Logic:

  • If the length of the string is greater than 140 characters
    • If the 141th character is a space then return first 140 characters
    • Else start from the 140th character and find the first space then return the return the string starting from the first index to the index where space was found.

Solution :