Skip to content

Commit df3b9f0

Browse files
refactor: use object literal rather than an array
1 parent ea1b46f commit df3b9f0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/commands/tasks.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,22 @@ const fetchTask = async key => {
7676
key = keys.slice(-1).pop();
7777
}
7878

79-
let taskAlreadyCompleted = [];
79+
let taskInfo = {};
8080

8181
// Holding reference to keys of all the completed tasks
8282
let previousKeys = keys.slice(0, taskCount);
8383

8484
previousKeys.some((item, index) => {
8585
if (item === key) {
86-
taskAlreadyCompleted = [true, index];
86+
taskInfo = {
87+
completed: true,
88+
count: index,
89+
};
8790
return true;
8891
}
8992
});
9093

91-
if (taskAlreadyCompleted[0]) {
94+
if (taskInfo.completed) {
9295
console.log();
9396
console.log(chalk.yellow.bold(' This task is already completed!'));
9497
console.log();
@@ -102,7 +105,7 @@ const fetchTask = async key => {
102105
),
103106
);
104107
console.log();
105-
console.log(chalk.green(`${exercises[taskAlreadyCompleted[1]].task}`));
108+
console.log(chalk.green(`${exercises[taskInfo.count].task}`));
106109
console.log();
107110
return;
108111
}

0 commit comments

Comments
 (0)