0

I am trying to delete a specific array element which I am getting from the user input. I want to delete not by Index but by the input which users type but it is always deleting the first element of the array. Can someone explain and correct my code? I really appreciate it.

else if(input === "delete"){
    let del = prompt("Delete a player from your Dream Team:")
    if(dreamTeam.includes(del)){
        let deletedPlayer = dreamTeam.splice(del, 1);
        console.log(del);
        console.log(`${deletedPlayer} is now deleted from your Dream Team.`);
    } else{
        console.log(`${del} is not a player listed in your Dream Team!`);
    }  
}
Riyad
  • 1
  • 1

0 Answers0