Skip to content

Commit 878e946

Browse files
committed
Exercise typescript with arrays and objects
1 parent cf4112e commit 878e946

File tree

2 files changed

+54
-19
lines changed

2 files changed

+54
-19
lines changed

sandbox.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1-
var character = 'mario';
2-
var age = 30;
3-
var isBlackBelt = false;
4-
character = 'luigi';
5-
age = 40;
6-
isBlackBelt = true;
7-
var circ = function (diameter) {
8-
return diameter * Math.PI;
1+
// arrays
2+
var names = ['luigi', 'mario', 'yoshi'];
3+
names.push('toad');
4+
// names.push(3);
5+
// names[0] = 3;
6+
var numbers = [10, 20, 30, 40];
7+
numbers.push(25);
8+
// numbers.push('shaun');
9+
var mixed = ['ken', 4, 'chun-li', 8, 9];
10+
mixed.push('ryu');
11+
mixed.push(10);
12+
mixed[0] = 3;
13+
// objects
14+
var ninja = {
15+
name: 'mario',
16+
belt: 'black',
17+
age: 30
18+
};
19+
ninja.age = 40;
20+
ninja.name = 'Ryu';
21+
// ninja.age = 'thirty';
22+
ninja = {
23+
name: 'yoshi',
24+
belt: 'orange',
25+
age: 40
926
};
10-
console.log(circ('hello'));

sandbox.ts

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,34 @@
1-
let character = 'mario';
2-
let age = 30;
3-
let isBlackBelt = false;
1+
// arrays
2+
let names = ['luigi', 'mario', 'yoshi'];
43

5-
character = 'luigi';
4+
names.push('toad');
5+
// names.push(3);
6+
// names[0] = 3;
67

7-
age = 40;
8+
let numbers = [10, 20 , 30, 40];
89

9-
isBlackBelt = true;
10+
numbers.push(25);
11+
// numbers.push('shaun');
1012

11-
const circ = (diameter: number) => {
12-
return diameter * Math.PI
13-
}
13+
let mixed = ['ken', 4, 'chun-li', 8, 9];
14+
15+
mixed.push('ryu');
16+
mixed.push(10);
17+
mixed[0] = 3;
18+
19+
// objects
20+
let ninja = {
21+
name: 'mario',
22+
belt: 'black',
23+
age: 30
24+
};
1425

15-
console.log(circ('hello'))
26+
ninja.age = 40;
27+
ninja.name = 'Ryu';
28+
// ninja.age = 'thirty';
29+
30+
ninja = {
31+
name: 'yoshi',
32+
belt: 'orange',
33+
age: 40
34+
}

0 commit comments

Comments
 (0)