8
I need to share a string in specific Javascript size.
I know it’s possible to use the Join
to transform a string
in a array
letter:
'hello'.split('')
However, I need a way where I can determine the size at which this string will be broken.
For example, in PHP, we have the function str_split
where you can determine the size of these strings.
In the example below, I want to divide the string every three.
str_split ('stackoverflow', 3)
Upshot:
[
"sta",
"cko",
"ver",
"flo",
"w",
]
Is there any way to do this in Javascript?
Ah, it’s true! You can use the
substring
also :D– Wallace Maxters