Need help on javascript pls

Tell us what’s happening:

javascript pls

Your code so far


var buffer = new ArrayBuffer(Bytesize);
var i32View = new int32Array(buffer);



Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763.

Challenge: Typed Arrays

Link to the challenge:
https://www.freecodecamp.org/learn/coding-interview-prep/data-structures/typed-arrays

Did you have a question?

What exactly are you trying to achieve?

to create a buffer witch is 64 bytes and in16array long.

Here’s a repl that creates a 64 byte buffer, and then creates three different views: a DataView, an Int16Array and an Int8Array. The same buffer is used for each interface.

Forgot that repl.it does the whole embedded weirdness. Anyway, this all works fine:

const byteSize = 64;

//Create a 64byte buffer 
let buffer = new ArrayBuffer(byteSize);

//Create a DataView referring to the buffer 
const view1 = new DataView(buffer);

// Create an Int16Array view referring to the buffer
const view2 = new Int16Array(buffer);

//Create a Int8Array view referring to the buffer 
const view3 = new Int8Array(buffer);

//Put value of 32bits 
view1.setInt32(0, 0x76543210);

//prints the 32bit value 
console.log(`DataView (int32): ${view1.getInt32(0).toString(16)}`);

// prints the 16bit value
console.log(`16Bit value: ${view2[0].toString(16)}`);

//prints only 8bit value  
console.log(`DataView (int8): ${view1.getInt8(0).toString(16)}`);
console.log(`Int8Array, no dataview: ${view3[0].toString(16)}`); 

Letting me interface with the same data via three different views. Hope this helps.