Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

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 :

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *