I know that maybe i will sound stupid for some people , but i am trying to extract single value from my array and insert it into a variable . How was possible to do it . In my case i want to have a new variable with the value only of the fileId
const arrayOfFiles = rowData.files;
Output :
[{…}, {…}]
0: {fileId: 166, fileExtension: "CSV"}
1: {fileId: 167, fileExtension: "XLSX"}
lastIndex: (...)
lastItem: (...)
length: 2
__proto__: Array(0)
Tryout
arrayOfFiles.forEach(file=> console.log(file.fileId));
Output
166
167
But how can i insert this value into a single variable ? I gave a try something like this :
const fileId = arrayOfFiles.forEach((file) => file.fileId);
But it returns me undefined . Any suggestions what am i doing wrong ?
fileIdto have?166or167? Or maybe an array with both? Or is that not what you're asking?const fileIdshould be equal tofile.fileId, because on click i can detect which id is requested