-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram_21.ts
41 lines (39 loc) · 1.16 KB
/
program_21.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* They think of something you could store in a TypeScript Object.
* Write a program that creates Objects containing these items.
*/
// Object representing information about different countries
let countriesInfo: { [country: string]: { capital: string, population: number, language: string } } = {
"USA": {
capital: "Washington, D.C.",
population: 331000000,
language: "English"
},
"China": {
capital: "Beijing",
population: 1441000000,
language: "Mandarin"
},
"India": {
capital: "New Delhi",
population: 1393000000,
language: "Hindi"
},
"Brazil": {
capital: "Brasília",
population: 213000000,
language: "Portuguese"
},
"Russia": {
capital: "Moscow",
population: 146700000,
language: "Russian"
}
};
// Print information about each country
for (let country in countriesInfo) {
console.log(`Country: ${country}`);
console.log(`Capital: ${countriesInfo[country].capital}`);
console.log(`Population: ${countriesInfo[country].population}`);
console.log(`Language: ${countriesInfo[country].language}\n`);
}