For example I have some random string:
str = \"26723462345\"
And I want to split it in 2 parts after 6-th char. How to do this correctly?>
Here's a reusable version for you:
str = "26723462345" n = str.length boundary = 6 head = str.slice(0, boundary) # => "267234" tail = str.slice(boundary, n) # => "62345"
It also preserves the original string, which may come in handy later in the program.