Created
March 5, 2013 17:18
-
-
Save nick-jonas/5092017 to your computer and use it in GitHub Desktop.
Add between last two words in a body of text to avoid orphans.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var orig = 'My sample body text', | |
split = orig.split(' '), | |
lastTwo = split.splice(split.length - 2); | |
lastTwo = lastTwo.join(' '); | |
split = split.join(' ') + ' ' + lastTwo; | |
orig = split; | |
// orig = 'My sample body text' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment