We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7610987 commit 9bd2356Copy full SHA for 9bd2356
1 file changed
js-core/homeworks/homework-9/src/main.js
@@ -129,10 +129,16 @@ let junior = {};
129
130
// fn.length == arguments.length
131
132
-function addMethod(object, name, fn) {
133
-
+const addMethod = (object, name, fn) => {
+ object[name] = function() {
134
+ if (fn.length == arguments.length) {
135
+ return fn;
136
+ }
137
+ };
138
+ return fn();
139
}
140
141
+
142
addMethod(junior, 'ok', function() {
143
console.log('zero arguments');
144
});
0 commit comments