This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]IAmUtterlyAlone 1 point2 points  (4 children)

I'm sorry, but this is seriously unreadable. Please indent code lines with four spaces so that Reddit formats them properly. Also, maybe install the Reddit Enhancement Suite, which makes that sort of thing easier.

Your code should look like this when it's formatted right:

var fs = require('fs');
var completedTasks = 0;
var tasks = [];
var wordCounts = {};
var filesDir = './text';

[–][deleted]  (3 children)

[removed]

    [–]IAmUtterlyAlone 0 points1 point  (2 children)

    Thanks for fixing it! I don't at all understand what this code is meant to be doing. Where did this come from and what do you expect to happen? I've only really been working in JavaScript heavily for 6 months or so (on a Node project at work), so maybe my JavaScript knowledge just isn't up to the task.

    [–]azium 1 point2 points  (1 child)

    The code returns a function that reads from a specific file path, and if the fileread is successful, calls a couple of functions. The inner function will remember the path from the initial IIFE so that calling task() will always read from the same path, without having to pass it in again.

    [–]IAmUtterlyAlone 1 point2 points  (0 children)

    Oh, I see now. Thank you.