Skip to content

Instantly share code, notes, and snippets.

@buymed-hoangpham
Created September 11, 2022 09:48
Show Gist options
  • Save buymed-hoangpham/2c693750041586fc373e5a835e2f0465 to your computer and use it in GitHub Desktop.
Save buymed-hoangpham/2c693750041586fc373e5a835e2f0465 to your computer and use it in GitHub Desktop.
8
const computers = [
{ type: 'Laptop', price: 124, os: 'Windows' },
{ type: 'Desk', price: 124, os: 'Mac' },
{ type: 'Desk', price: 124, os: 'Windows' },
{ type: 'Laptop', price: 124, os: 'Mac' },
{ type: 'Laptop', price: 124, os: 'Windows' },
];
let totalTotalMacComputers = 0;
let totalTotalWindowsComputers = 0;
computers.forEach((computer) => {
if (computer.os === 'Mac') totalTotalMacComputers++;
if (computer.os === 'Windows') totalTotalWindowsComputers++;
return computer;
});
console.log(
'๐Ÿš€ ~ file: index.js ~ line 10 ~ totalTotalMacComputers',
totalTotalMacComputers
);
console.log(
'๐Ÿš€ ~ file: index.js ~ line 12 ~ totalTotalWindowsComputers',
totalTotalWindowsComputers
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment