Chrome Extension

Get first 10 words from string javascript

function getWordStr(str) {
    return str.split(/\s+/).slice(0,10).join(" ");

var fullStr = "We can get first 10 words form this string using the above function";
var finalStr = getWordStr(fullStr);


Do you know, you can create and search your own code snippets on Devsheet. Store your code on cloud using devsheet and search using its chrome extension. Is it look cool?

We can get first 10 words form this string using

The code snippet can be used to get first 10 words from a string. You can set start and end points in the 'getWordStr' function. We have applied a start point form 0 and end point to 10. 

Search Index Data (The code snippet can also be found with below search text)

Get n words string from another string javascript
Was this helpful?
Never leave your website again in search of code snippets by installing our chrome extension.