Skip to content

Commit 9bd2356

Browse files
homework-9
1 parent 7610987 commit 9bd2356

File tree

1 file changed

+8
-2
lines changed
  • js-core/homeworks/homework-9/src

1 file changed

+8
-2
lines changed

js-core/homeworks/homework-9/src/main.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,16 @@ let junior = {};
129129

130130
// fn.length == arguments.length
131131

132-
function addMethod(object, name, fn) {
133-
132+
const addMethod = (object, name, fn) => {
133+
object[name] = function() {
134+
if (fn.length == arguments.length) {
135+
return fn;
136+
}
137+
};
138+
return fn();
134139
}
135140

141+
136142
addMethod(junior, 'ok', function() {
137143
console.log('zero arguments');
138144
});

0 commit comments

Comments
 (0)