mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-28 03:34:26 +03:00
perf(sum): Improve performance of sum (#167)
This commit is contained in:
parent
6aca4b2f4a
commit
34be6d7611
@ -14,8 +14,8 @@
|
||||
export function sum(nums: readonly number[]): number {
|
||||
let result = 0;
|
||||
|
||||
for (const num of nums) {
|
||||
result += num;
|
||||
for (let i = 0; i < nums.length; i++) {
|
||||
result += nums[i];
|
||||
}
|
||||
|
||||
return result;
|
||||
|
Loading…
Reference in New Issue
Block a user