Place string based on the format on an Array

Hi all sorry if the title is not right but i don’t know how to put it in a title haha, my first post!

explanation: I have a javascript code in a file and i want to put it as text in an Array!
also heads up, i am using React-ts

Basically the js file:

console.log('test me')
const data = 'my data'
const numbData = 1233
const myObj = {data: 123123}
const myArr = ['ewqeqw', '132312']
function myFunc(param) {
    console.log(param)
}
myFunc('testFunc')

What i tried:

  const [updated, setUpdate] = useState<boolean>(false);
  const [file, setFile] = useState();
  const areaRef = useRef<HTMLTextAreaElement | null>(null);
  const codeRef = useRef<HTMLParagraphElement | null>(null);

  const reader = new FileReader();

  function handleChange(event: any) {
    setFile(event.target.files[0]);
  }

  reader.addEventListener('loadend', function () {
    document.getElementById('newText').innerHTML = reader.result;
    setUpdate(true);
  });

  if (file) {
    reader.readAsText(file);
  }

  if (updated) {
    let data = codeRef.current?.innerText;
    let bodyTextArray = data?.split(/(n)/);
    console.log(data);
    console.log(bodyTextArray);
  }

What i get :
Console Log result

What i want:

[“console.log(‘test me’)”, “const data = ‘my data'”, “const numbData = 1233”, “const myObj = {data: 123123}”, “const myArr = [‘ewqeqw’, ‘132312’]”, “function myFunc(param) {
console.log(param)
}”, “myFunc(‘testFunc’)”]

Basically every peice of code (variable declaration, functions…) on it’s own!

Thank you and any solution would be be appreciated!