JS: Random Name picker: How do I remove things from the array names[] as I remove list,,,
The title won't make sense. Ok, in this input you type a name and press add. This adds/creates a list. (i++). The list's innerHTML (input.value) gets pushed into this array names[] that we will be randomizing by pressing the "pickRancom" button. When you click on the right border of the list, the list is removed. But the text that matches the deleted list doesn't get removed. Like this: list: Jack. names[Jack]; As the Jack list is created, the text also gets pushed in the names[] array: names[Jack]; Now, when you delete the Jack list, *the Jack from the names[] array should be removed too.* And remember that I'm just using Jack as an example. Realisticly there are gonna be more elements like: list: Jack, list: Heather, list: Jim; names[Jack, Heather, Jim]; Why I want to do this is because, Even though Jack is removed from the list, the names[] array still has Jack, so when you click pickRandom, it will still pick random Jack, instead of undefined. <- that shouldn't happen. When Jack is removed from the list, it should also be removed from the names[]. Forgot the code again: https://code.sololearn.com/WphlX5xuimCR/#js