2
2
3
3
## Identifiers
4
4
5
- 1 . Define variable to store your name.
6
- 2 . Define constant to store your birth year.
5
+ 1 . Define variable to store your name as a string .
6
+ 2 . Define constant to store your birth year as a number .
7
7
3 . Prepare function to print greeting with single argument.
8
- 4 . Call function passing value.
8
+ 4 . Call function passing value as literal .
9
9
5 . Call function passing variable.
10
+ 6 . Call function passing constant.
10
11
11
12
## Loop
12
13
17
18
18
19
1 . Implement function ` average ` with signature
19
20
` average(a: number, b: number): number ` calculating average (arithmetic mean).
20
- 2 . Implement function ` square ` with signature
21
+ 2 . Implement function ` square ` with signature
21
22
` square(x: number): number ` calculating square of x.
22
- 3 . Implement function ` cube ` with signature
23
+ 3 . Implement function ` cube ` with signature
23
24
` cube(x: number): number ` calculating cube of x.
24
25
4 . Call functions ` square ` and ` cube ` in loop, then pass their results to
25
26
function ` average ` . Print what ` average ` returns.
@@ -32,13 +33,13 @@ function `average`. Print what `average` returns.
32
33
Explain script behaviour.
33
34
4 . Implement function ` createUser ` with signature
34
35
` createUser(name: string, city: string): object ` . Example:
35
- ` createUser('Marcus Aurelius', 'Roma') ` will return
36
+ ` createUser('Marcus Aurelius', 'Roma') ` will return object
36
37
` { name: 'Marcus Aurelius', city: 'Roma' } `
37
38
38
39
## Array
39
40
40
41
1 . Define array of objects with two fields: ` name ` and ` phone ` (phone book).
41
- Example: ` { name: 'Marcus Aurelius', phone: '+380445555555 ' } ` .
42
+ Example: ` { name: 'Marcus Aurelius', phone: '+380445554433 ' } ` .
42
43
2 . Implement function ` findPhoneByName ` with signature
43
44
` findPhoneByName(name: string): string ` . Returning phone from that object
44
45
where field ` name ` equals argument ` name ` . Use ` for ` loop for this search.
0 commit comments