Function icon indicating copy to clipboard operation
Function copied to clipboard

Extend test cases with passing a named function

Open timagixe opened this issue 2 years ago • 0 comments

According to MDN (source):

If function name is omitted, it will be the variable name (implicit name).
If function name is present, it will be the function name (explicit name).

Code exmaple:

const foo = function () {};
foo.name // "foo"

const foo2 = foo;
foo2.name // "foo"

const bar = function baz() {};
bar.name // "baz"

I suggest extending test cases with the following case:

diff --git a/Exercises/4-methods.test b/Exercises/4-methods.test
index a408b22..78eb07d 100644
--- a/Exercises/4-methods.test
+++ b/Exercises/4-methods.test
@@ -10,11 +10,15 @@
         },
         m3(x, y, z) {
           return [x, y, z];
-        }
+        },
+        m4: function sum(x, y) {
+          return x + y;
+        },
       }, [
         ['m1', 1],
         ['m2', 2],
-        ['m3', 3]
+        ['m3', 3],
+        ['sum', 2],
       ]
     ],
   ]

timagixe avatar Jan 22 '23 17:01 timagixe