Quiz 18: Callback functions used well and badly
Question 1
Shows
true?JavaScript
function handle(callback) {
const result = [];
callback(result);
return result;
}
let it = [];
handle(it => it.push(1)).length === 1Question 2
Shows
true?JavaScript
function handle(callback) {
const result = [];
callback(result);
return result;
}
handle(() => it.push(1)).length === 1Question 3
Shows
true?JavaScript
function handle(callback) {
const result = [];
callback(result);
return result;
}
handle(it.push(1)).length === 1Question 4
Shows
true?JavaScript
function handle(callback) {
const result = [];
callback([]);
return result;
}
handle(it => it.push(1)).length === 1Question 5
Shows
true?JavaScript
function handle(callback) {
const result = [];
return callback(result);
}
handle(() => [1]).length === 1Question 6
Shows
true?JavaScript
function handle(callback) {
const result = [];
callback(result);
return result;
}
handle(it => it.push(1)).length === 1Question 7
Shows
true?JavaScript
function handle(callback) {
return callback([]);
}
handle(it => {
it.push(1);
return it;
}).length === 1Question 8
Shows
true?JavaScript
function handle(callback) {
const result = [];
callback(result);
return result;
}
let it = [];
handle(it.push(1)).length === 1Question 9
Shows
true?JavaScript
function handle(callback) {
const result = [];
callback(result);
callback(result);
return result;
}
handle(it => it.push(1)).length === 2Question 10
Shows
true?JavaScript
function handle(callback) {
const result = [];
callback(result);
return result;
}
let it = [];
handle(() => it.push(1)).length === 1Question 11
Shows
true?JavaScript
function handle(callback) {
const result = [];
callback(result);
return result;
}
handle(() => [1]).length === 1Question 12
Shows
true?JavaScript
function handle(count, callback) {
const result = [];
for (let i = 0; i < count; i++) {
callback(result);
}
return result;
}
handle(3, it => it.push(1)).length === 3