Created
September 9, 2014 08:56
-
-
Save lukaszgrolik/e3e93f252f148343d2cf to your computer and use it in GitHub Desktop.
utils.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function capitalizeFirstLetter(string) | |
{ | |
return string.charAt(0).toUpperCase() + string.slice(1); | |
} | |
function moveArrayElement(arr, old_index, new_index) { | |
while (old_index < 0) { | |
old_index += arr.length; | |
} | |
while (new_index < 0) { | |
new_index += arr.length; | |
} | |
if (new_index >= arr.length) { | |
var k = new_index - arr.length; | |
while ((k--) + 1) { | |
arr.push(undefined); | |
} | |
} | |
arr.splice(new_index, 0, arr.splice(old_index, 1)[0]); | |
return arr; // for testing purposes | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment