Infinite Method Object - Problem
Write a function that returns an infinite-method object. An infinite-method object is defined as an object that allows you to call any method name and it will always return the name of the method as a string.
For example, if you execute obj.abc123(), it should return "abc123". If you call obj.hello(), it should return "hello".
The object should work with any valid JavaScript method name and should handle chaining as well.
Input & Output
Example 1 — Basic Method Call
$
Input:
obj.abc123()
›
Output:
"abc123"
💡 Note:
The infinite method object intercepts the call to 'abc123' and returns the method name as a string
Example 2 — Different Method Name
$
Input:
obj.hello()
›
Output:
"hello"
💡 Note:
Any valid JavaScript identifier can be called as a method, returning its name
Example 3 — Complex Method Name
$
Input:
obj.myMethod123ABC()
›
Output:
"myMethod123ABC"
💡 Note:
Even complex method names with numbers and mixed case work correctly
Constraints
- Must work with any valid JavaScript identifier
- Method calls should return the method name as a string
- Should handle alphanumeric method names
- No predefined limit on method names
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code