Skip to content

Commit f03c355

Browse files
committed
complete ts chapter - 4
1 parent a156e5a commit f03c355

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| 1: Getting started with TypeScript | [Readme](/chapters/1/readme.md) |
66
| 2: Why and when to use TypeScript | [Readme](/chapters/2/readme.md) |
77
| 3: TypeScript Core Types | [Readme](/chapters/3/readme.md) |
8-
| 4: Arrays | [Readme]() |
8+
| 4: Arrays | [Readme](/chapters/4/app.ts) |
99
| 5: Enums | [Readme]() |
1010
| 6: Functions | [Readme]() |
1111
| 7: Classes | [Readme]() |

chapters/4/app.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
let Inventory = [
2+
{name: 'apples', quantity: 2},
3+
{name: 'bananas', quantity: 0},
4+
{name: 'cherries', quantity: 5}
5+
];
6+
7+
function findCherries(fruit) {
8+
return fruit.name === 'cherries';
9+
}
10+
11+
let oneDataOnArray = Inventory.filter((e) => e.name === 'apples')[0];
12+
console.log(oneDataOnArray); // { name: 'apples', quantity: 2 }
13+
14+
/******** Some how problem in .find() **********/
15+
//console.log(Inventory.find(findCherries)); // { name: 'cherries', quantity: 5 }
16+
//console.log(Inventory.find(findCherries)); // { name: 'cherries', quantity: 5 }

0 commit comments

Comments
 (0)