Skip to content

Commit acd0ac2

Browse files
committed
Added and completed "extend" for Underbar.
1 parent ec2f7ca commit acd0ac2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/underbar.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,16 @@ var _ = {};
248248
// bla: "even more stuff"
249249
// }); // obj1 now contains key1, key2, key3 and bla
250250
_.extend = function(obj) {
251+
// pull out the additional args into an array
252+
var args = Array.prototype.slice.call(arguments);
253+
var newProps=args.slice(1, args.length);
254+
255+
_.each(newProps, function(newObj) {
256+
_.each(newObj, function(val, key) {
257+
obj[key]=val;
258+
});
259+
});
260+
return obj;
251261
};
252262

253263
// Like extend, but doesn't ever overwrite a key that already

0 commit comments

Comments
 (0)