Skip to content

Commit

Permalink
fix : EsLInt error
Browse files Browse the repository at this point in the history
  • Loading branch information
dasom-jo committed Jan 2, 2025
1 parent c89c102 commit c194648
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/array/reduce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
export function reduce<T>(arr: T[], indicesToRemove: number[]): Array<T | undefined> {
// Normalize indices and sort in descending order
const indicesSet = Array.from(
new Set(
indicesToRemove.map((index) => (index < 0 ? arr.length + index : index))
)
new Set(indicesToRemove.map((index) => (index < 0 ? arr.length + index : index)))
).sort((a, b) => b - a);

const removed: Array<T | undefined> = [];

// Remove elements at specified indices
for (const index of indicesSet) {
for (let i = 0; i < indicesSet.length; i++) {
const index = indicesSet[i];
if (index >= 0 && index < arr.length) {
removed.unshift(arr[index]); // Add the removed element to the front
arr.splice(index, 1); // Remove the element from the array
Expand Down

0 comments on commit c194648

Please sign in to comment.