Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save emmettnicholas/4191c5344a69f9e4668d to your computer and use it in GitHub Desktop.
Save emmettnicholas/4191c5344a69f9e4668d to your computer and use it in GitHub Desktop.
Code Fellows dev bootcamp application question
// QUESTION
// What does the following JavaScript code do?
var
obj1 = {value: 1},
obj2 = {value: 2},
obj3 = {value: 3};
var ValueCollect = function() {
var values = [];
var operation = function(obj) {
if (obj) {
values.push(obj.value);
return values;
}
else {
return values;
}
};
};
var accumulator = ValueCollect();
accumulator(obj1);
accumulator(obj2);
// POSSIBLE ANSWERS (multiple choice)
// (A) The code will work as designed by collecting all object values in values array
// (B) The code will hold only one object value at any given time
// (C) The code will not work because obj1 and obj2 are declared outside the ValueCollect function and will be treated as undefined
// (D) The code will not work because operation function is incomplete
// (E) The code will work only if ValueCollect function is declared before declaring obj1 and obj2
@emmettnicholas
Copy link
Author

@ayax79 ... so which answer would you choose?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment