1
2
3
4
5
6
7
8
9
10
To practice on your own, or to check code you believe shouldn't have been scored as incorrect, go to CodePen.
0,1,2,3,4,5,6,7,8,9
0
0
0
0
A callback is a named, anonymous, or arrow function passed as an ______ to another function. | argument | argument | |
In the following code, what is the name of the callback? | calcTotal(5, 31, displayTotal); | displayTotal | displayTotal |
Fill in the blank. The first line of the callback function is... function payCompliment() { |
document.querySelector("button").addEventListener("click",________); | payCompliment | payCompliment |
Code the first line of a function that has a named callback as the argument. Make up the names. | function calc(anotherFunc) { | function[a-z_$][a-zA-Z0-9_$]*\([a-z_$][a-zA-Z0-9_$]*\){ | |
Fill in the blanks with an anonymous function as the callback. The callback displays an alert. Make up the alert text. | setTimeout(________ ______________ _, 2000); |
function() { alert("2 seconds have passed"); } |
function\(\){[\r\n]alert\(•.*•\);[\r\n]} |
Code a setTimeout() statement. The callback is an arrow function without brackets that displays an alert after 5 seconds. Make up the alert text. | setTimeout(() => alert("Hello"), 5000); | setTimeout\(\(\)=>{?alert\(•.*•\)}?,5000\); | |
Rewrite the addEventListener() statement below, substituting an anonymous function as the callback. | function sayHi() { alert("Hi"); } document.querySelector("button").addEventListener("click", sayHi); |
document.querySelector("button").addEventListener("click", function() { alert("Hi"); }); |
document\.querySelector\(•button•\)\.addEventListener\(•click•,function\(\){[\r\n]?alert\(•Hi•\);[\r\n]?}\); |
A button has been assigned to the variable btn. A paragraph has been assigned to the variable p. When the button is clicked, some textContent is inserted into the paragraph by an arrow callback. Make up the paragraph text. Don't use brackets in the arrow callback. | btn.addEventListener("click", () => p.textContent = "You clicked"); | btn\.addEventListener\(•click•,\(\)=>{?p\.textContent=•.*•\)}?; | |
|
|||
|