Menu
Coddy logo textTech

Öge Kaldır

Coddy'nin JavaScript Journey'sinin Temeller bölümünün bir parçası — ders 73 / 77.

challenge icon

Görev

Kolay

Şimdi, bir dize (öğe) alan ve onu listeden çıkaran removeItem adında bir fonksiyon ekleyin.

Sonuç olarak, fonksiyon şu çıktıyı verecektir:

Milk removed from the grocery list.

"Milk" girdisi için.

Ve eğer öğe listede yoksa:

Milk is not in the grocery list.

 

 

Kodunuzu test etmek için kodunuzun sonuna aşağıdaki kodu ekleyin (önceki test kodu yerine):

addItem("Milk");
addItem("Bread");
addItem("Eggs");
removeItem("Bread");
removeItem("Cheese");

Kendin dene

// Grocery list array
let groceryList = [];

// Function to add an item to the grocery list
function addItem(item) {
	groceryList.push(item);
	console.log(`${item} added to the grocery list.`);
}

addItem("Milk");
addItem("Bread");
addItem("Eggs");

Temeller bölümündeki tüm dersler