swati-jagtap / javascript-practice

0 stars 0 forks source link

9.2.3--Declare a function called categorizeCountries which returns an array of countries which have some common pattern #122

Closed swati-jagtap closed 3 years ago

swati-jagtap commented 3 years ago
const countries = ['Finland', 'Sweden', 'Denmark', 'Norway', 'Iceland']
const names = ['Asabeneh', 'Mathias', 'Elias', 'Brook']
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const products = [
  { product: 'banana', price: 3 },
  { product: 'mango', price: 6 },
  { product: 'potato', price: ' ' },
  { product: 'avocado', price: 8 },
  { product: 'coffee', price: 10 },
  { product: 'tea', price: ' ' },
]
//9.2.3--Declare a function called categorizeCountries which returns an array of countries which have some common 
function categorizeCountries(countries){
const a=countries.filter((c)=>c.endsWith("d"))
return a;
}
console.log(categorizeCountries(countries))

image

function categorizeCountries(countries){
const a=countries.filter((c)=>c.includes("en"))
return a;
}
console.log(categorizeCountries(countries))

image