Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/School-Work / School Work/Turn Objects into Flexible Arrays/index.js |
| Date | Not specified in source |
| Repository | Janady13/School-Work |
| Revision | 4a666c890caf7c43c47d0572dbcc287373c7a78e |
| Branch | main |
| Path or archive member | School Work/Turn Objects into Flexible Arrays/index.js |
| Original SHA-256 | 61c74e56c0bc7d1c32190d30f5550eceabc963117adb590aad4a9ed1600ffe04 |
| Git blob SHA | 58c0022691eeebb8b6ca46b38b94a9316cc4b4ab |
| Reading-copy SHA-256 | 61c74e56c0bc7d1c32190d30f5550eceabc963117adb590aad4a9ed1600ffe04 |
Recovered source transcript
Download complete source text ↓41 lines · 1.0 KB
const obj = { one: 1, two: 2 };
for (const key in obj) {
console.log('value', obj[key]);
}
//object.keys(), Object.values(), Object.entries()
const user ={
name: 'John',
age: 29
};
Object.keys(user).includes("age");
Object.keys(user).map(key => user[key]);
// You can replace all the previous code that is written by using the Object.values()method
Object.values(user)
// If you console log this you get the same results as the code above.
//get the monthly total of all the expenses
const monthlyExpenses = {
food: 400,
rent: 1700,
insurance: 550,
internet: 49,
phone: 95
};
// This is how you would get the total monthly cost of expenses useing Objects and the reduced function.
const total = Object.values(monthlyExpenses).reduce((acc, expense) => acc + expense , 0);
// Object.entries give you the array of arrays. It is splitting up the arrays and giving them back to you.
console.log(total)
console.log(values);
console.log(ageExists);