Here, we will look at a coding challenge that involves the array method concat() along with the forEach() array method.
//Molly keeps her business expenses separated into 4 different arrays.
//She needs to combine them into one array for tax purposes.
//Your task is to combine all arrays into one array for expenses. Then give a summary statement for her expenses and the total.
class Item {
constructor(itemName, amount) {
this.itemName = itemName;
this.amount = amount;
}
}
const officeExp = [
new Item("Supplies", 30),
new Item("Computer", 900),
new Item("Utilities", 150),
new Item("Software", 200),
];
const travelExp = [
new Item("Meals", 800),
new Item("Entertainment", 500),
new Item("Car Rentals", 700),
new Item("Flights", 900),
];
const payroll = [
new Item("Jacobs", 900),
new Item("Bryan", 900),
new Item("Davis", 900),
new Item("Edison", 900),
new Item("Brown", 600),
];
const fees = [
new Item("state", 300),
new Item("federal", 600),
new Item("city", 900),
];
0:00 Instructions for the coding challenge
1:19 Using the concat() method
2:40 Setting up variables
3:50 Setting up the forEach() method
5:15 Getting a total
JavaScript Playlist:
• JavaScript for Beginners
MDN concat() Method:
https://developer.mozilla.org/en-US/d...
MDN forEach() Method:
https://developer.mozilla.org/en-US/d...
MDN Classes:
https://developer.mozilla.org/en-US/d...
NodeJS:
nodejs.org
VS Code:
code.visualstudio.com
Информация по комментариям в разработке