forked from danielstern/array.visualize
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharray_basics.html
65 lines (61 loc) · 2.72 KB
/
array_basics.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
62
63
64
65
<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<title>Array basics</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<link rel="stylesheet" href="styles/main.css">
</head>
<body>
<div class="container my-5">
<h1>Array Visualizer</h1>
<h3 class="mb-5">See how JavaScript arrays work</h3>
<div class="mb-5">
<h4 id="ex_1">Get a value by index</h4>
<p>To get a value of an array at a specific index, we use square brackets <code>[]</code>.</p>
<pre>
var arr = ['Johnny', 'David', 'Sarah'];
</pre>
<div id="_one"></div>
<p>Click one of the below buttons to highlight the value by index</p>
<div id="_one_buttons">
<button data-index="0">arr[0]</button>
<button data-index="1">arr[1]</button>
<button data-index="2">arr[2]</button>
</div>
</div>
<div class="mb-5">
<h4 id="ex_2">Get a value in a nested array</h4>
<p>To get a value of a nested array, we use two square brackets <code>[]</code>. The first one accesses values in the parent array, the second one accesses values in the nested array.</p>
<pre>
var arr = [['Johnny', 'David'], ['Tom', 'Paul']];
</pre>
<div class="parens d-inline-block">[</div>
<div id="_two_1" class="d-inline-block" style="vertical-align: bottom;"></div>
<span>,</span>
<div id="_two_2" class="d-inline-block" style="vertical-align: bottom;"></div>
<div class="parens d-inline-block">]</div>
<p class="mt-5">Click one of the below buttons to highlight the value by index</p>
<div id="_two_buttons_1" class="d-inline-block">
<button data-index="0">arr[0][0]</button>
<button data-index="1">arr[0][1]</button>
</div>
<div id="_two_buttons_2" class="d-inline-block">
<button data-index="0">arr[1][0]</button>
<button data-index="1">arr[1][1]</button>
</div>
</div>
</div>
<footer class="container">
<p class="mb-0">For <a href="https://www.altcademy.com/">Altcademy.com</a></p>
<p>Array.visualize library by <a href="https://github.com/danielstern/array.visualize">danielstern</a></p>
</footer>
<script src="./scripts/jquery.js"></script>
<script src="./scripts/d3/d3.js"></script>
<script src="./array.visualize.js"></script>
<script src="./scripts/array_basics.js"></script>
</body>
</html>