I'm a beginner to vanilla JS and was building this program to remove a specific item from an array. However it's bit tricky.
let cart = ['bread', 'milk', 'rice'];
while (6 > 0){
let remove = prompt("Enter The Item You Want to Remove");
if (remove.toLowerCase() === "done"){
break
}
else{
for (let j = 0; j < cart.length; j++){
if (remove.toLowerCase() === cart[j].toLowerCase()){
cart.splice(cart[j],1);
}
}
}
}
Can you give me the solution to remove a specific item from an array. Thank You