-
Notifications
You must be signed in to change notification settings - Fork 0
/
rAddStar.html
executable file
·61 lines (46 loc) · 1.46 KB
/
rAddStar.html
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
<!--
/*****************************************/
// This is a frame for running snippets of JSX. // Try to name those snippets with an r(eact) at the front!
/*****************************************/
// Given a list of strings, return a list in React where each string has "*" added at its end.
// addStar(["a", "bb", "ccc"]) → ["a*", "bb*", "ccc*"]
// addStar(["hello", "there"]) → ["hello*", "there*"]
// addStar(["*"]) → ["**"]
-->
<!DOCTYPE html>
<html>
<head>
<title>Coding Bat solution</title>
<script src="https://unpkg.com/[email protected]/dist/react.js"></script>
<script src="https://unpkg.com/[email protected]/dist/react-dom.js"></script>
<script src="https://unpkg.com/[email protected]/babel.min.js"></script>
<script type="text/babel">
function Star(props) {
return (
<h1> We think highly of the number: {props.tally[1]}. </h1>
)
}
function Show(props) {
let backAtcha = "";
while (props.tally.length > 0){
backAtcha = backAtcha + props.tally[0] + "* ";
props.tally.shift();
}
console.log(backAtcha);
return <h2> {backAtcha }</h2>;
}
ReactDOM.render(
<div>
<Show tally={["a", "bb", "ccc"]} />
<Show tally={["hello", "there"]} />
<Show tally={[101, 102, 103]} />
<Show tally={["*"]} />
</div>
, document.getElementById('mountNode')
);
</script>
</head>
<body>
<div id="mountNode"></div>
</body>
</html>