Complete the code to create a Buffer from a string.
const buf = Buffer.[1]('hello');
The Buffer.from() method creates a new Buffer containing the given string.
Complete the code to concatenate two Buffers.
const combined = Buffer.[1]([buf1, buf2]);Buffer.concat() joins multiple Buffers into one.
Fix the error in the code to concatenate buffers with a total length.
const combined = Buffer.concat([bufA, bufB], [1]);bufA + bufB which concatenates objects incorrectlybufA.size which is undefinedThe second argument to Buffer.concat() is the total length of the new buffer, which is the sum of the lengths of the buffers.
Fill both blanks to create two buffers and concatenate them.
const buf1 = Buffer.[1]('Node'); const buf2 = Buffer.[2]('JS'); const result = Buffer.concat([buf1, buf2]);
Use Buffer.from() to create buffers from strings before concatenating.
Fill all three blanks to create buffers, concatenate, and convert to string.
const bufA = Buffer.[1]('Hello, '); const bufB = Buffer.[2]('World!'); const combined = Buffer.[3]([bufA, bufB]); console.log(combined.toString());
Create buffers from strings using Buffer.from(), then join them with Buffer.concat(). Finally, convert the combined buffer to a string.