Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export default {
// TODO: this doesn't quite work, because the `workspaces` directory is
// ignored by Prettier at the top-level...
"*.{graphql,json,md,js,jsx,mjs,ts,tsx,mts}": "prettier --write",
};
5 changes: 4 additions & 1 deletion workspaces/javascript-leetcode-month/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export { default } from "@code-chronicles/eslint-config";
import config from "@code-chronicles/eslint-config";

// TODO: get to the point where we can use the lint
export default [...config, { ignores: ["problems/"] }];
3 changes: 0 additions & 3 deletions workspaces/javascript-leetcode-month/hello.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 2703. Return Length of Arguments Passed

[View Problem on LeetCode](https://leetcode.com/problems/return-length-of-arguments-passed/)

This problem is essentially testing familiarity with [JavaScript's rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters). However, there is also a solution that doesn't rely on rest parameters. Do you know it? It's hinted at in the documentation link.

Once you've worked on the problem, check out [the full write-up and solution](solution.md).

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @return {number}
*/
const argumentsLength = function () {
return arguments.length;
};

/**
* argumentsLength(1, 2, 3); // 3
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const argumentsLength = function (..._args: readonly unknown[]): number {
return arguments.length;
};

/**
* argumentsLength(1, 2, 3); // 3
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function argumentsLength(...[]: readonly unknown[]): number {
return arguments.length;
}

/**
* argumentsLength(1, 2, 3); // 3
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @return {number}
*/
function argumentsLength() {
return arguments.length;
}

/**
* argumentsLength(1, 2, 3); // 3
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function argumentsLength(..._args: readonly unknown[]): number {
return arguments.length;
}

/**
* argumentsLength(1, 2, 3); // 3
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const argumentsLength = (...args: readonly unknown[]) => args.length;

/**
* argumentsLength(1, 2, 3); // 3
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const argumentsLength = (...args: readonly unknown[]): number => args.length;

/**
* argumentsLength(1, 2, 3); // 3
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @param {...(null|boolean|number|string|Array|Object)} args
* @return {number}
*/
function argumentsLength(...args) {
return args.length;
}

/**
* argumentsLength(1, 2, 3); // 3
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function argumentsLength(...args: readonly unknown[]): number {
return args.length;
}

/**
* argumentsLength(1, 2, 3); // 3
*/
Loading