Skip to content

Commit efc2ab0

Browse files
committed
Add exercises
1 parent 75a47c2 commit efc2ab0

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Exercises.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Exercises
2+
3+
## Hoisting
4+
5+
1. Implement function containing local variable with hoisting.
6+
2. Commit example to github.
7+
3. Use eslint to find this problem and --fix flag to remove it.
8+
4. Fix example manually and commit it to github.
9+
10+
## Scalar value vs Reference
11+
12+
Prepare two implementations of `inc` function:
13+
1. First with signature `inc(n: number): number`,
14+
call example: `let a = 5; const b = inc(a); console.dir({ a, b });`
15+
2. Second with signature `inc(num: Num)` where `Num` is object with field `n`,
16+
so function will change field of the object passed by reference,
17+
call example: `let obj = { n: 5} ; inc(obj); console.dir(obj);`
18+
19+
## Types
20+
21+
1. Prepare array with values of different type.
22+
2. Prepare collection (object) with type names as keys and `0` as values,
23+
example: `{ number: 0, string: 0 }` and so on for all types.
24+
3. Iterate array with `for..of` loop and increment occurrence counter there
25+
to get collection of types occurrences count for all types in array.
26+
4. Modify this example: remove all keys from initial collection literal and
27+
add all keys dynamically from the loop.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy