Reputation: 6986
I have an array that looks like this,
[
"slug.current == 'current'",
"parent->slug.current == 'parentSlug'",
"parent->parent->slug.current == 'parentParentSlug'",
"parent->parent->parent->slug.current == 'parentParentParentSlug'"
]
This is created via this code,
path.split('/')
.filter(i => i)
.reverse()
.map((slug, i) => {
return `${'parent->'.repeat(i)}slug.current == '${slug}'`;
});
I am wanting to remove the "parent->slug.current == 'parentSlug'" from ever being the error I would like to disregard after the split if possible,
I though it would need to something like,
path.split('/')
.filter(i => i)
.reverse()
.splice(2, 2)
.map((slug, i) => {
return `${'parent->'.repeat(i)}slug.current == '${slug}'`;
});
This returns the below,
[
"slug.current == 'current'",
"parent->slug.current == 'parentSlug'"
]
when what I want is,
[
"slug.current == 'current'",
"parent->slug.current == 'parentParentSlug'",
"parent->parent->slug.current == 'parentParentParentSlug'"
]
Upvotes: 0
Views: 58
Reputation: 630
change splice to this
.splice(1,1)
first argument is the index, second one means how many items after this index should be deleted (including the index it self)
Upvotes: 1