1번 - After running the following code, what will be the value of result?
function doubleUp (f, x) {
return f( f(x) );
};
function subject (value) {
return value + "!";
};
var result = doubleUp(subject, "hi");
1번 질문의 답을 선택하세요. *
"hi"
"hi!"
"hi!!"
"hi!!!!"
2번 - After running the following code, what will be the value of result? (You may look up JavaScript ternary operator if you need to.)
function eitherOne (f, g, x) {
return (x % 2 === 0) ? f(x) : g(x);
};
var result = eitherOne(
function (x) { return x + 5 },
function (x) { return x - 5 },
15
)
2번 질문의 답을 선택하세요. *
5
10
15
20
30
3번 - After running the following code and all setTimeouts have run their callbacks, what will be the value of result?
var result = 10;
function wait (time, f) {
setTimeout(function () {
result = f(result);
}, time);
}
wait(500, function (x) { return x + 5 })
wait(250, function (x) { return x * 2 })
3번 질문의 답을 선택하세요. *
0점
10
15
20
25
30
4번 - Using the concept of callbacks, write the exercise function so that result will equal 42.
function exercise (???) {
???
}
var a = exercise(10, function (x) {
return x + 2;
});
var b = exercise(15, function (x) {
return x * 2;
});
var result = a + b;
4번 질문의 답을 적어주세요. *
0점
내 답변
5번 - After the following code runs, what will be the value of result?
function foo () {
var data = 10;
bar(function (players) {
data = players;
});
return data;
}
function bar (callback) {
callback(20);
}
var result = foo();
5번 질문의 답을 선택하세요. *
0점
10
20
undefined
6번 - After the following code runs and all setTimeout callbacks run, what will be the value of result?
function foo () {
var data = 10;
bar(function (players) {
data = players;
});
return data;
}
function bar (callback) {
setTimeout(function () {
callback(20);
}, 500); // 리턴 이후 20초후에 20으로 데이터 값 변경
}
var result = foo();
6번 질문의 답을 선택하세요. *
0점
10
20
undefined
7번 - After the following code runs and all setTimeout callbacks run, what will be the value of result?
function foo () {
var data = 10;
bar(function (players) {
data = players;
});
return data;
}
function bar (callback) {
setTimeout(callback, 0);
}
var result = foo();
7번 질문의 답을 선택하세요. *
0점
10
20
undefined
'코드스테이츠(Immersive) > 체크포인트' 카테고리의 다른 글
Checkpoints 12 - Chatterbox Server (0) | 2019.08.14 |
---|---|
Checkpoints 10 - Order of Execution (0) | 2019.07.28 |
Checkpoints 09 - Value vs. Reference (0) | 2019.07.28 |
Checkpoint 7 - Function Binding (0) | 2019.07.27 |
Checkpoints 04 - JS Prototypes(Object.create) (0) | 2019.07.24 |