I have been trying to make the code below work, which is a part of deletion function. However, the splice method inside the for-loop keeps returning an error when it\'s run.