Skip to content

Commit

Permalink
refactor: replace parseInt() with Number()
Browse files Browse the repository at this point in the history
  • Loading branch information
artemtam committed Dec 3, 2024
1 parent 2751a28 commit f77ef83
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion 2023/day-01/solution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @param str
*/
const parseDigit = (str: string): number | null => {
const digit = Number.parseInt(str);
const digit = Number(str);
return !Number.isNaN(digit) ? digit : null;
}

Expand Down
2 changes: 1 addition & 1 deletion 2023/day-03/solution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const isSymbol = (str: string): boolean => {
};

const isNumber = (str: string): boolean => {
return !Number.isNaN(parseInt(str));
return !Number.isNaN(Number(str));
};

const isGear = (str: string): boolean => {
Expand Down
8 changes: 4 additions & 4 deletions 2024/day-01/solution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export const solvePart1 = (input: string): number => {
for (const line of input.trim().split('\n')) {
const [a, b] = line.trim().split(' ');

listA.push(Number.parseInt(a, 10));
listB.push(Number.parseInt(b, 10));
listA.push(Number(a));
listB.push(Number(b));
}

// sort both lists
Expand All @@ -32,8 +32,8 @@ export const solvePart2 = (input: string): number => {
for (const line of input.trim().split('\n')) {
const values = line.trim().split(' ');

const a = Number.parseInt(values[0], 10);
const b = Number.parseInt(values[1], 10);
const a = Number(values[0]);
const b = Number(values[1]);

listA.push(a);
listB.set(b, (listB.get(b) ?? 0) + 1);
Expand Down

0 comments on commit f77ef83

Please sign in to comment.