TobilobaCodes – LeetCode Explorer

2703. Return Length of Arguments Passed

In this page, we will explore LeetCode Problem 2703: Return Length of Arguments Passed. This is a beginner-friendly JavaScript challenge involving rest parameters and argument counting.

📄 Problem Statement

Write a function argumentsLength that returns the number of arguments passed to it.

💡 Example

Input:
argumentsLength(1, 2, 3)
Output:
3

Input:
argumentsLength('a')
Output:
1

Input:
argumentsLength()
Output:
0

🧠 Explanation

The rest parameter syntax ...args allows a function to accept an indefinite number of arguments as an array. Using args.length, we can easily count how many values were passed when the function was called.

This problem tests your understanding of ES6 features like rest parameters.

✅ Your Solution


/**
 * @return {number}
 */
var argumentsLength = function(...args) {
    return args.length;
};