Skip to content

Instantly share code, notes, and snippets.

@buymed-hoangpham
Created September 11, 2022 09:01
Show Gist options
  • Save buymed-hoangpham/2e12b6dc046967a70f4058f06b81eab0 to your computer and use it in GitHub Desktop.
Save buymed-hoangpham/2e12b6dc046967a70f4058f06b81eab0 to your computer and use it in GitHub Desktop.
3
const products = [
{ name: 'Iphone', price: 200 },
{ name: 'Motorola', price: 70 },
{ name: 'Samsung', price: 150 },
{ name: 'Sony', price: 98 },
{ name: 'Windows pone', price: 10 },
];
const result = products.map(
(product) => `Name: ${product.name} Price. - Price: ${product.price}$`
);
result.forEach((item) => console.log(item));
@QuocCao-dev
Copy link

const products = [
  { name: "Iphone", price: 200 },
  { name: "Motorola", price: 70 },
  { name: "Samsung", price: 150 },
  { name: "Sony", price: 98 },
  { name: "Windows pone", price: 10 },
];

const showProductInfo = (product) => {
  console.log(`Name: ${product.name} Price. - Price: ${product.price}$`);
};

products.forEach(showProductInfo);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment