After India’s Strike on Pakistan, Both Sides Leave Room for De-escalation
Copy// Create an array of shoe objects
const shoes = [
{
id: 1,
brand: 'Nike',
model: 'Air Max',
color: 'Black',
price: 99.99
},
{
id: 2,
brand: 'Adidas',
model: 'Superstar',
color: 'White',
price: 79.99
},
{
id: 3,
brand: 'Puma',
model: 'Suede',
color: 'Blue',
price: 69.99
}
];
// Function to display shoe details
const displayShoeDetails = (shoe) => {
console.log(`Brand: ${shoe.brand}`);
console.log(`Model: ${shoe.model}`);
console.log(`Color: ${shoe.color}`);
console.log(`Price: $${shoe.price}`);
console.log('--------------------------');
};
// Function to display all shoes
const displayAllShoes = () => {
console.log('----- ALL SHOES -----');
shoes.forEach((shoe) => {
displayShoeDetails(shoe);
});
};
// Function to search for a shoe by brand
const searchByBrand = (brand) => {
console.log(`Searching for shoes by brand: ${brand}`);
const foundShoes = shoes.filter((shoe) => shoe.brand.toLowerCase() === brand.toLowerCase());
if (foundShoes.length === 0) {
console.log('No shoes found');
} else {
console.log(`Found ${foundShoes.length} shoes:`);
foundShoes.forEach((shoe) => {
displayShoeDetails(shoe);
});
}
};
// Display all shoes on the website
displayAllShoes();
// Search for shoes by brand
searchByBrand('nike');
Comments
Post a Comment