KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm not very good with string manipulation in JavaScript, and I was wondering how you would go about shortening a string without cutting any word off. I know how to use substring, but not indexOf or anything really well. Say I had the following string: text = "this is a long string I cant display" I want to trim it down to 10 characters, but if it doesn't end with a space, finish the word. I don't want the string variable to look like this: "this is a long string I cant dis" I want it to finish the word until a space occurs.
Tags (comma-separated)
Save Edits
Cancel