Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use strict; /* Question 03 Write a function which takes in two file paths and can sum the numbers found in each file. For example,

"use strict";

/* Question 03

Write a function which takes in two file paths and can sum the numbers found in each file.

For example,

Given: - filePath1 points to a txt file which contains "42" - filePath2 points to a txt file which contains "24"

Then: - call the callback with the number 66

The callback should be called with two arguments (an error object, followed by data) as is typical in Node. The data passed in should therefore be the second argument, not the first.

The callback should be called with two arguments: 1. error: if there is an fs error, pass it through to this callback. otherwise set this argument to null 2. data: if there is no error, this should be the sum (number). If there is an error, this should be set to null.

- The function should support negative and decimal point numbers. - Don't worry about other edge cases. For example, you can assume that if the given files are there, they WILL contain valid numbers.

*/

const sumFileData = function(filePath1, filePath2, callback) {

// IMPLEMENT ME };

// Don't change below: module.exports = { sumFileData };

please use above statements and solve this

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What advice would you provide to Jennifer?

Answered: 1 week ago

Question

What are the issues of concern for each of the affected parties?

Answered: 1 week ago