0

Please see the two blocks of code below. the first block of code is expected to perform the same way as the second block. But in the second block where function names are passed to other functions,it does not work and throws error. Note:-This is related to one of the modules in freecodecamp nodejs training.

FIRST BLOCK:-

request.pipe(map(function(chunk){return   chunk.toString().toUpperCase()})).pipe(response)

is different from SECOND BLOCK:-

request.pipe(transStream).pipe(response);
var transStream = map(data);

 function data (chunk)
  {
    return chunk.toString().toUpperCase();  
  }

the second block of code does not work while the first one does any help is greatly appreciated

1 Answer 1

1

I guess the code below should work:

var transStream = map(data);
request.pipe(transStream).pipe(response);
function data (chunk)
{
  return chunk.toString().toUpperCase();  
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.