Advertisement
Guest User

Untitled

a guest
Oct 15th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.35 KB | None | 0 0
  1. <html>
  2.  
  3. <body>
  4. <div class="container">
  5. <div class="row" id="question-one">
  6. <div class="header">Question One</div>
  7. </div>
  8. <div class="row" id="question-two">
  9. <div class="header">Question Two</div>
  10. </div>
  11. <div class="row" id="question-three">
  12. <div class="header">Question Three</div>
  13. </div>
  14. <div class="row" id="question-four">
  15. <div class="header">Question Four</div>
  16. </div>
  17. <div class="row" id="question-five">
  18. <div class="header">Question Five</div>
  19. </div>
  20. </div>
  21. </body>
  22. <script type="text/javascript">
  23.  
  24. var users= [
  25. {
  26. "id": 1,
  27. "name": "Leanne Graham",
  28. "username": "Bret",
  29. "email": "Sincere@april.biz",
  30. "address": {
  31. "street": "Kulas Light",
  32. "suite": "Apt. 556",
  33. "city": "Gwenborough",
  34. "zipcode": "92998-3874",
  35. "geo": {
  36. "lat": "-37.3159",
  37. "lng": "81.1496"
  38. }
  39. },
  40. "phone": "1-770-736-8031 x56442",
  41. "website": "hildegard.org",
  42. "company": {
  43. "name": "Romaguera-Crona",
  44. "catchPhrase": "Multi-layered client-server neural-net",
  45. "bs": "harness real-time e-markets"
  46. }
  47. },
  48. {
  49. "id": 2,
  50. "name": "Ervin Howell",
  51. "username": "Antonette",
  52. "email": "Shanna@melissa.tv",
  53. "address": {
  54. "street": "Victor Plains",
  55. "suite": "Suite 879",
  56. "city": "Wisokyburgh",
  57. "zipcode": "90566-7771",
  58. "geo": {
  59. "lat": "-43.9509",
  60. "lng": "-34.4618"
  61. }
  62. },
  63. "phone": "010-692-6593 x09125",
  64. "website": "anastasia.net",
  65. "company": {
  66. "name": "Deckow-Crist",
  67. "catchPhrase": "Proactive didactic contingency",
  68. "bs": "synergize scalable supply-chains"
  69. }
  70. },
  71. {
  72. "id": 3,
  73. "name": "Clementine Bauch",
  74. "username": "Samantha",
  75. "email": "Nathan@yesenia.net",
  76. "address": {
  77. "street": "Douglas Extension",
  78. "suite": "Suite 847",
  79. "city": "McKenziehaven",
  80. "zipcode": "59590-4157",
  81. "geo": {
  82. "lat": "-68.6102",
  83. "lng": "-47.0653"
  84. }
  85. },
  86. "phone": "1-463-123-4447",
  87. "website": "ramiro.info",
  88. "company": {
  89. "name": "Romaguera-Jacobson",
  90. "catchPhrase": "Face to face bifurcated interface",
  91. "bs": "e-enable strategic applications"
  92. }
  93. },
  94. {
  95. "id": 4,
  96. "name": "Patricia Lebsack",
  97. "username": "Karianne",
  98. "email": "Julianne.OConner@kory.org",
  99. "address": {
  100. "street": "Hoeger Mall",
  101. "suite": "Apt. 692",
  102. "city": "South Elvis",
  103. "zipcode": "53919-4257",
  104. "geo": {
  105. "lat": "29.4572",
  106. "lng": "-164.2990"
  107. }
  108. },
  109. "phone": "493-170-9623 x156",
  110. "website": "kale.biz",
  111. "company": {
  112. "name": "Robel-Corkery",
  113. "catchPhrase": "Multi-tiered zero tolerance productivity",
  114. "bs": "transition cutting-edge web services"
  115. }
  116. },
  117. {
  118. "id": 5,
  119. "name": "Chelsey Dietrich",
  120. "username": "Kamren",
  121. "email": "Lucio_Hettinger@annie.ca",
  122. "address": {
  123. "street": "Skiles Walks",
  124. "suite": "Suite 351",
  125. "city": "Roscoeview",
  126. "zipcode": "33263",
  127. "geo": {
  128. "lat": "-31.8129",
  129. "lng": "62.5342"
  130. }
  131. },
  132. "phone": "(254)954-1289",
  133. "website": "demarco.info",
  134. "company": {
  135. "name": "Keebler LLC",
  136. "catchPhrase": "User-centric fault-tolerant solution",
  137. "bs": "revolutionize end-to-end systems"
  138. }
  139. },
  140. {
  141. "id": 6,
  142. "name": "Mrs. Dennis Schulist",
  143. "username": "Leopoldo_Corkery",
  144. "email": "Karley_Dach@jasper.info",
  145. "address": {
  146. "street": "Norberto Crossing",
  147. "suite": "Apt. 950",
  148. "city": "South Christy",
  149. "zipcode": "23505-1337",
  150. "geo": {
  151. "lat": "-71.4197",
  152. "lng": "71.7478"
  153. }
  154. },
  155. "phone": "1-477-935-8478 x6430",
  156. "website": "ola.org",
  157. "company": {
  158. "name": "Considine-Lockman",
  159. "catchPhrase": "Synchronised bottom-line interface",
  160. "bs": "e-enable innovative applications"
  161. }
  162. },
  163. {
  164. "id": 7,
  165. "name": "Kurtis Weissnat",
  166. "username": "Elwyn.Skiles",
  167. "email": "Telly.Hoeger@billy.biz",
  168. "address": {
  169. "street": "Rex Trail",
  170. "suite": "Suite 280",
  171. "city": "Howemouth",
  172. "zipcode": "58804-1099",
  173. "geo": {
  174. "lat": "24.8918",
  175. "lng": "21.8984"
  176. }
  177. },
  178. "phone": "210.067.6132",
  179. "website": "elvis.io",
  180. "company": {
  181. "name": "Johns Group",
  182. "catchPhrase": "Configurable multimedia task-force",
  183. "bs": "generate enterprise e-tailers"
  184. }
  185. },
  186. {
  187. "id": 8,
  188. "name": "Nicholas Runolfsdottir V",
  189. "username": "Maxime_Nienow",
  190. "email": "Sherwood@rosamond.me",
  191. "address": {
  192. "street": "Ellsworth Summit",
  193. "suite": "Suite 729",
  194. "city": "Aliyaview",
  195. "zipcode": "45169",
  196. "geo": {
  197. "lat": "-14.3990",
  198. "lng": "-120.7677"
  199. }
  200. },
  201. "phone": "586.493.6943 x140",
  202. "website": "jacynthe.com",
  203. "company": {
  204. "name": "Abernathy Group",
  205. "catchPhrase": "Implemented secondary concept",
  206. "bs": "e-enable extensible e-tailers"
  207. }
  208. },
  209. {
  210. "id": 9,
  211. "name": "Glenna Reichert",
  212. "username": "Delphine",
  213. "email": "Chaim_McDermott@dana.io",
  214. "address": {
  215. "street": "Dayna Park",
  216. "suite": "Suite 449",
  217. "city": "Bartholomebury",
  218. "zipcode": "76495-3109",
  219. "geo": {
  220. "lat": "24.6463",
  221. "lng": "-168.8889"
  222. }
  223. },
  224. "phone": "(775)976-6794 x41206",
  225. "website": "conrad.com",
  226. "company": {
  227. "name": "Yost and Sons",
  228. "catchPhrase": "Switchable contextually-based project",
  229. "bs": "aggregate real-time technologies"
  230. }
  231. },
  232. {
  233. "id": 10,
  234. "name": "Clementina DuBuque",
  235. "username": "Moriah.Stanton",
  236. "email": "Rey.Padberg@karina.biz",
  237. "address": {
  238. "street": "Kattie Turnpike",
  239. "suite": "Suite 198",
  240. "city": "Lebsackbury",
  241. "zipcode": "31428-2261",
  242. "geo": {
  243. "lat": "-38.2386",
  244. "lng": "57.2232"
  245. }
  246. },
  247.  
  248. "phone": "024-648-3804",
  249. "website": "ambrose.net",
  250. "company": {
  251. "name": "Hoeger LLC",
  252. "catchPhrase": "Centralized empowering task-force",
  253. "bs": "target end-to-end models"
  254. }
  255. }
  256. ];
  257.  
  258. //containers
  259. let part1 = document.getElementById("question-one");
  260. let part2 = document.getElementById("question-two");
  261. let part3 = document.getElementById("question-three");
  262. let part4 = document.getElementById("question-four");
  263. let part5 = document.getElementById("question-five");
  264.  
  265. //part 1
  266. let name = [];
  267. for( let i = 0; i < users.length; i++){
  268.  
  269. //create row
  270. let row = document.createElement("p");
  271. row.innerHTML = users[i].name;
  272. part1.appendChild(row);
  273. }
  274.  
  275. //part 2
  276. let geo = [];
  277. for( let i = 0; i < users.length; i++){
  278.  
  279. //create row
  280. let row = document.createElement("p");
  281. row.innerHTML = "lat: " + users[i].address.geo.lat + " , " + "long: " + users[i].address.geo.lng;
  282. part2.appendChild(row);
  283. }
  284.  
  285.  
  286. //part 3
  287. let user_objects = [];
  288. //function to make an object and display them
  289. function user(name,id,company,zipcode){
  290. this.name;
  291. this.id;
  292. this.company;
  293. this.zipcode;
  294.  
  295. //create row
  296. let row = document.createElement("p");
  297. row.innerHTML = "name: " + name + " id: "+ id + " company: " + company + " zipcode: " +zipcode;
  298. part3.appendChild(row);
  299. }
  300. //store all the information needed as an object array
  301. for( let i = 0; i < users.length; i++){
  302.  
  303. let name = users[i].name;
  304. let id = users[i].id;
  305. let company = users[i].company.name;
  306. let zipcode = users[i].address.zipcode;
  307. user(name,id,company,zipcode);
  308. user_objects.push(user);
  309.  
  310. }
  311.  
  312. //part 4
  313. let street_names = [];
  314. for( let i = 0; i < users.length; i++){
  315.  
  316. if(users[i].address.zipcode[0] == "5"){
  317. let row = document.createElement("p");
  318. row.innerHTML = users[i].address.street;
  319. part4.appendChild(row);
  320. }
  321. }
  322.  
  323.  
  324.  
  325. //part 5
  326. let ids = [];
  327. //store the id's
  328. for( let i = 0; i < users.length; i++){
  329. ids.push(users[i].id);
  330. }
  331.  
  332. let total = ids[0];
  333. for( let i = 0; i<ids.length; i++){
  334. total = total * ids[i];
  335. }
  336.  
  337. //create row
  338. let row = document.createElement("p");
  339. row.innerHTML = "result: " + total;
  340. part5.appendChild(row);
  341.  
  342.  
  343. </script>
  344. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement