Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. WDI Week 2 Assessment
  2. Congratulations on your second week of WDI!
  3.  
  4. To help us track your progress from the last week, please answer the following questions to the best of your ability:
  5.  
  6. 1. DOM
  7.  
  8. # Write a line of code that will create a button:
  9. var button = document.createElement('button');
  10.  
  11.  
  12. # Write a line of code that will append that button to the document body:
  13. body.appendChild('button');
  14.  
  15.  
  16. # Write a line of code that will give the button a class of 'clicked':
  17. button.onclick = function(){
  18.  
  19. }
  20.  
  21. # Write code that will give the button a click handler and log 'hello'
  22. # to the console when it is clicked:
  23. button.onclick = function(){
  24. console.log('hello');
  25. }
  26.  
  27. # Write code that will give the button a click handler and log **this** button
  28. # object to the console when it is clicked:
  29. button.onclick = function(){
  30. var hello = "this"
  31. console.log(hello);
  32. }
  33.  
  34. # If you type 'this' straight into the console, you will get an object called
  35. # Window. Explain in one sentence what this object is:
  36. How many times that item is logged.
  37.  
  38. 2. CALLBACKS
  39.  
  40. # A fellow student shows you this code. When he runs it, he expects it to
  41. # wait three seconds, then write "Ding!" to the console. Instead, it writes
  42. # "Ding!" immediately. Find the bug and fix it.
  43.  
  44. function writeDing() {
  45. console.log('Ding!');
  46. }
  47.  
  48. var dingHandle = setTimeout (writeDing(), 3000);
  49.  
  50. Write your answer here:
  51. 3. MISC - ARRAYS AND OBJECTS
  52.  
  53. # Given the following multi-dimensional array, write the code that will log
  54. # "Eddard" to the console:
  55. gameOfThrones[1][2];
  56. var gameOfThrones = [["Joffrey", "Stannis", "Renly"], ["Arya", "Sansa", "Eddard"]];
  57.  
  58.  
  59. # Given the following object, write the code that will log "Ramsay" to the
  60. # console:
  61. gameOfThrones2.boltons[1];
  62. var gameOfThrones2 = { boltons: ["Roose", "Ramsay"],
  63. greyjoys: ["Balon", "Theon"]}
  64.  
  65.  
  66. # Write the code that will change "Theon" within the gameOfThrones2 object to "Reek":
  67. gameOfThrones2.greyjoys.pop()
  68. gameOfThrones2.greyjoys.push('Reek')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement