Skip to content

Commit 6db3d65

Browse files
committed
added more comments and updated README
1 parent ba4bf05 commit 6db3d65

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ npm install
55
npm test
66

77
## Description
8-
This repo is designed to give students a better understanding of how to use callbacks to deal with async operations in Javascript. Complete each of the exercises in the exercises directory and test your code!
8+
This repo is designed to give students a better understanding of how to use callbacks to deal with async operations in Javascript. Complete each of the exercises in the exercises directory. The comments in each exercise will guide you. Test your code to see if it works!

exercises/parse.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const fs = require("fs");
2-
/* ASYNC-TEXT-PARSE
2+
/* READ
33
In this exercise, you need to utilize the provided functions as callbacks so that the
44
tests pass. The input file contains space-separated numbers on multiple lines of a
55
.txt file. Just by filling in the appropriate callbacks, you should be able to
@@ -35,13 +35,15 @@ false
3535
3636
/* ---------------------------- */
3737

38-
// replace references to this function
38+
// DO NOT EDIT; replace the references to it with references to other functions
3939
function PLACEHOLDER() {};
4040

4141
// call the callback to initiateParse so that it only runs after parsing is complete
4242
function initiateParse(callback) {
43+
// begins the parsing process by reading input
4344
fs.readFile(__dirname + '/../input.txt', 'utf8', PLACEHOLDER);
44-
45+
46+
// writes output to output file
4547
function writeOutput(err, data) {
4648
let output = '';
4749
for (let i = 0; i < data.length; i++) {
@@ -55,7 +57,8 @@ function initiateParse(callback) {
5557
if (err) throw err;
5658
});
5759
};
58-
60+
61+
// async function that sums lines and determines if they add up to more than 100
5962
function calculateLines(data, cb) {
6063
let filteredData = data.map(function(el) {
6164
let values = el.split(' ');
@@ -74,6 +77,7 @@ function initiateParse(callback) {
7477
}, 100);
7578
};
7679

80+
// splits string by line
7781
function splitLines(err, data) {
7882
if (err) throw err;
7983
let input = data.toString().split('\n');

exercises/request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var fs = require('fs');
22
var http = require('http');
33

4-
4+
// READ
55
// The get request in this function retrieves data on Harry Potter characters from an API.
66
// The parsedData received from this API will be an array containing character objects.
77
// Each character object has several properties. The only properties relevant to us are

0 commit comments

Comments
 (0)