- Notifications
You must be signed in to change notification settings - Fork 349
/
Copy path03-PowerOfJSX_ts.tsx
63 lines (59 loc) · 2.13 KB
/
03-PowerOfJSX_ts.tsx
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
importReactfrom'react';
/**
*🏆
* The goal here is to get you more familiar with JSX.
* You will use javascript code inside JSX to loop through object keys
* and render a div element for each element in that object
*/
functionCompanyProfile(props){
/**
* 💡 some variables to store mock data
* We will use these data to display the company profile information
*/
conststockTicker='APPL';
constcompanyProfileInfo={
'Company Name': 'Apple Inc.',
'Price': 150,
'Exchange': "Nasdaq Global Select",
'Industry': "Computer Hardware",
'CEO': 'Timothy D. Cook'
}
return(
<div>
<div>Profile of: {/**✏️ display stock ticker here*/}</div>
<hr/>
<div>
{
/**
* ✏️
* This block is surrounded by curly braces {} so
* we can really execute any Javascript stuff here.
*
* Loop through the keys of companyProfileInfo
* object to render one div per key/value pair. The div should
* render key followed by a colon followed by value.
*
* 🧭 Object.keys(obj) can be used to loop through the object
* eg:
* const obj = { 'key1': 'value1', 'key2': 'value2'};
* Object.keys(obj) will return ['key1', 'key2']
* 🧭 You can use Array.map() to map any key to a div element
* eg:
* ['a', 'b', 'c'].map(d => <div>{d}</div>)
* 🧭 Remember to use curly braces inside the div to render
* any text content you want
*/
}
</div>
</div>
);
}
/**
* 🚨 🚨 DO NOT DELETE OR CHANGE THIS.🚨 🚨
* This is how you would use your above component and
* the output of this code is displayed on the browser
*/
constUsage=(props)=>{
return<CompanyProfile/>
}
exportdefaultUsage;