Okay, so now we'll talk about kind of killing two birds with one stone, we're going to remove elements and add elements at the same time. So once again, back to the full array with five elements. And then here, I'm going to call the splice method and pass it the first organism one. So I'm saying start at position one, or letter B, the letter B is remove one element, so remove B, and then insert one element, which is the letter X. So what I should get is an array back with one element, which is B, which is the element that was removed. And then who should be now a x C, D. So I get the array back with one element.
And then when I inspect foo, I get a x C, D and E. So this is basically like a call. It's like a replace. It's a great way to replace any element in array. I could have said, let's see, we'll start over and we'll say foo equals this. And then we could say, food supplies and I'm going to say position three, sufficient three is ABCD. ABCD it's the letter D, we're going to say, remove one and add the letters x and y.
So we should get an array back with one element, which should be the letter D. And then we should be foo should become a, b, c x, y and E. I'll do that I get the letter D back and then when I inspect foo, I get ABC, x, y and D. So we did a replace, but we replaced one letter with two letters. And we could keep going, we could, we could, we could have inserted you know, 15 elements there. But the main thing to keep in mind is that with the splice method, you can can remove and insert elements at the same time. The first argument is the index where to start the second argument is the number of elements to remove and then the third argument or fourth or fifth and so on, is the element. You'd like to add and you can do that in one shot.