It seems like an easy problem, but i can't find solution. I want to take first, let's say 2 letters from string, and move them to the end of this string. So for example, OK12 would become 12OK.
edit: So far i've tried cutting string off, then adding it to the rest of the string, but i tought there's a one-line solution for that, like predefined function or something.
"OK12".substr(2) + "OK12".substr(0,2)
Generic solution:
var result = str.substr(num) + str.substr(0, num);
Live DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With