Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WDI Week 2 Assessment
- Congratulations on your second week of WDI!
- To help us track your progress from the last week, please answer the following questions to the best of your ability:
- 1. DOM
- # Write a line of code that will create a button:
- var button = document.createElement('button');
- # Write a line of code that will append that button to the document body:
- body.appendChild('button');
- # Write a line of code that will give the button a class of 'clicked':
- button.onclick = function(){
- }
- # Write code that will give the button a click handler and log 'hello'
- # to the console when it is clicked:
- button.onclick = function(){
- console.log('hello');
- }
- # Write code that will give the button a click handler and log **this** button
- # object to the console when it is clicked:
- button.onclick = function(){
- var hello = "this"
- console.log(hello);
- }
- # If you type 'this' straight into the console, you will get an object called
- # Window. Explain in one sentence what this object is:
- How many times that item is logged.
- 2. CALLBACKS
- # A fellow student shows you this code. When he runs it, he expects it to
- # wait three seconds, then write "Ding!" to the console. Instead, it writes
- # "Ding!" immediately. Find the bug and fix it.
- function writeDing() {
- console.log('Ding!');
- }
- var dingHandle = setTimeout (writeDing(), 3000);
- Write your answer here:
- 3. MISC - ARRAYS AND OBJECTS
- # Given the following multi-dimensional array, write the code that will log
- # "Eddard" to the console:
- gameOfThrones[1][2];
- var gameOfThrones = [["Joffrey", "Stannis", "Renly"], ["Arya", "Sansa", "Eddard"]];
- # Given the following object, write the code that will log "Ramsay" to the
- # console:
- gameOfThrones2.boltons[1];
- var gameOfThrones2 = { boltons: ["Roose", "Ramsay"],
- greyjoys: ["Balon", "Theon"]}
- # Write the code that will change "Theon" within the gameOfThrones2 object to "Reek":
- gameOfThrones2.greyjoys.pop()
- gameOfThrones2.greyjoys.push('Reek')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement