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 write the string 'Hi' into the buffer at offset 0.
buf.[1]('Hi', 0);
The write() method writes a string to the buffer starting at the specified offset.
Fix the error in reading an unsigned 16-bit integer from the buffer at offset 2.
const num = buf.[1](2);
readUInt16BE reads an unsigned 16-bit integer in big-endian format from the buffer at the given offset.
Fill both blanks to create a buffer of length 5 and fill it with the byte value 0x1F.
const buf = Buffer.[1](5); buf.[2](0x1F);
Buffer.alloc(5) creates a buffer of length 5, and fill(0x1F) fills it with the byte value 0x1F.
Fill all three blanks to create a buffer from a string, write 'OK' at offset 3, and read an unsigned 8-bit integer at offset 4.
const buf = Buffer.[1]('Example'); buf.[2]('OK', 3); const val = buf.[3](4);
Buffer.from('Example') creates a buffer from the string. write('OK', 3) writes 'OK' starting at offset 3. readUInt8(4) reads one byte as an unsigned integer at offset 4.