-
Notifications
You must be signed in to change notification settings - Fork 40
/
js_errors.html
96 lines (72 loc) · 2.93 KB
/
js_errors.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!--script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script -> -->
</head>
<body>
<div id="content">
<h2>Welcome to a Page of Errors</h2>
<p>In order to get the "You did it" to appear below here, you need to use your Chrome console window, fix the code in an editor, reload, and get the output of each of the problems to appear.</p>
<p>Send me a screen shot copy of your console output as "proof."</p>
</div>
</body>
<script type="text/javascript">
// this is a javascript function.
function simple_add(arg1, arg2) {
return arg1 + arg2;
}
// so is this. Because it's defined as a var, it needs to appear before it's referred to on the page.
var subtract = function(arg1, arg2) {
return arg1 - arg2;
};
// this is an object
var myobject = {
cats: 2,
dogs: 5,
burrowingOwl: 10
};
console.log("Welcome to the problems in Javascript that you should fix.");
var mydata = [
{
Name: "Alice",
Experience: 20,
Title: "Data Journalist"
},
{
Name: "Bob",
Experience: "10",
Title: "Associate Editor"
},
{
Name: "Carmen",
Experience: NaN,
Title: "Senior Editor"
}
];
// fix this to fill in your name and display this in the console.
//console.log("Hi, my name is " + your name here).
// fix this so you can refer to burrowing owls:
//console.log("Problem 1, owls:", myobject's burrowing owls);
// fix to call the function with the cats and dogs properly
//console.log("Problem 2, Add 2 values:", simple_add(myobject's cats, myobject's dogs));
// fix to reference the first object in the list.
console.log("Problem 3, the first json object is (fix the index in brackets):", mydata[<index>]);
// A very simple function is needed here...
console.log("Problem 4, print the size or length of the mydata array using the right function in place of the array object name here:", mydata);
// Fill in the function, args, and fix the args so this works:
console.log("Problem 5, subtract experience of Bob from Alice, which requires fixing the data so subtraction works:", <fill in function and args here>);
// Create another list of data objects expressing these estimates from 2014:
// Florida's population is 19,893,297, and it has 27 seats in the US House of Reps.
// California's population is 38,802,500, and it has 53 seats in the US House.
// Texas's pop is 26,956,958, and it has 36 seats in the US House.
//
// Create a function that calculates the population per house seat for any object.
// Console.log the output for all 3 states' pop per house seat.
console.log("Your page should now display the last h2 element...");
// Raw DOM manipulation without jquery or d3: fix the missing variable with the results of the part above.
var child = document.createElement("h2");
child.innerHTML = "You did it! Texas has a Population per House Seat of " + YourAnswerHere;
document.getElementById("content").appendChild(child);
</script>
</html>