Math, asked by sc0052245, 6 months ago

100words = 2words (a genius can understand) Is there anyone genius will reply me ​

Answers

Answered by BIGBRAIN1000
1

i can't I but I am genius because I know what I am.

...

Answered by Anonymous
6

Using slice(x, y) will give you elements from x to y, but using slice(x) will give you elements from x to the end of the array. (note: this will return the empty string if the description has less than 100 words.)

Here is some documentation.

You could also use a regex:

var short_description = description.replace(/^([^ ]+ ){100}/, '');

Here is an explanation of the regex:

^ beginning of string ( start a group [^ ] any character that is not a space + one or more times then a space ) end the group. now the group contains a word and a space. {100} 100 times

Then replace those 100 words with nothing. (note: if the description is less than 100 words, this regex will just return the description unchanged.)

Similar questions