Вы должны сохранить данные в массиве / varialbe за пределами l oop из l oop и убедиться, что они находятся в той же области, что и тот, который объявляет функцию, значение которой вы собираетесь использовать дюйм.
Это исправление, примененное к вашему решению (включая только его основные области)
var data = [ // Array of records for data, this would be the initial object that you are looping through
{ Name: "Bruh1" },
{ Name: "Bruh2" },
{ Name: "Bruh3" },
];
var arr = []; // Declare the array to take the data outside the loop
data.forEach((data) => {
arr.push(data.Name); // Push data.Name into an array outside the forEach loop
});
// Putting that data into your other function
console.log([
['Name', 'Percentage'],
["'" + arr[0] + "'", 1],
["'" + arr[1] + "'", 1],
["'" + arr[2] + "'", 1]
]);