Skip to content

Commit

Permalink
Utils.String.RemoveAt would incorrectly calculate the slice index i…
Browse files Browse the repository at this point in the history
…f it was > 0. It will now remove the correctly specified character.
  • Loading branch information
photonstorm committed Oct 14, 2024
1 parent 773dc8a commit eb7f17c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils/string/RemoveAt.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

/**
* Takes a string and removes the character at the given index.
*
* The index is zero based.
*
* @function Phaser.Utils.String.RemoveAt
* @since 3.50.0
*
* @param {string} string - The string to be worked on.
* @param {number} index - The index of the character to be removed.
* @param {number} index - The index of the character to be removed. This value is zero-based.
*
* @return {string} The modified string.
*/
Expand All @@ -23,7 +25,7 @@ var RemoveAt = function (string, index)
}
else
{
return string.slice(0, index - 1) + string.slice(index);
return string.slice(0, index) + string.slice(index + 1);
}
};

Expand Down

0 comments on commit eb7f17c

Please sign in to comment.