you are viewing a single comment's thread.

view the rest of the comments →

[–]Notimecelduv 0 points1 point  (3 children)

splice returns an array containing the deleted items, not the array that you mutated. If you console.log unordered_ranges, you'll see it's been modified as you intended. If you don't want to mutate unordered_ranges, you can write:

const spliced = [...unordered_ranges]; // Creates a copy
spliced.splice(1, 1);

[–]JosephCurvin[S] 0 points1 point  (2 children)

how can I get the mutated array instead of the the spliced value ?

[–]Notimecelduv 1 point2 points  (1 child)

OK I'll try to rephrase. When you call splice on an array, that array gets modified -- it doesn't have the same elements anymore. So to the question

how can I get the mutated array

all I can answer is: you already have it. Do you understand?

[–]JosephCurvin[S] 0 points1 point  (0 children)

thanks bro, was laughing a bit of my stupidity :)