Skip to content

Commit d51861a

Browse files
Bob-chemistDzyubSpirit
authored andcommitted
No need to check if args.length is equal to 0
We have already equated `x` to `res`. So, if `args` is empty, loop will be skipped and `x` will be returned by default as `res`.
1 parent 9e9861d commit d51861a

1 file changed

Lines changed: 0 additions & 2 deletions

File tree

JavaScript/5-loop.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const compose = (...fns) => x => {
4-
if (fns.length === 0) return x;
54
const last = fns.length - 1;
65
let res = x;
76
for (let i = last; i >= 0; i--) {
@@ -11,7 +10,6 @@ const compose = (...fns) => x => {
1110
};
1211

1312
const pipe = (...fns) => x => {
14-
if (fns.length === 0) return x;
1513
let res = x;
1614
for (let i = 0; i < fns.length; i++) {
1715
res = fns[i](res);

0 commit comments

Comments
 (0)