Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function update_array(str, slinger_array) {
- for (var i = 0; i < str.length(); i++) { // Loop through each character of the string
- if (slinger_array[i] == undefined) { // If array element does not exist yet, push new element
- slinger_array.push({
- "slinger_char": {
- "id": i,
- "character": str.charAt(i)
- }
- });
- }
- else // if the array element exists, update only the character
- {
- slinger_array[i].character = str.charAt(i);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement