Если шрифт моноширинный, то, условно, так:
const minGap = 3;
const keys = ['name', 'price'];
const input = [
{
name: "абрикосы",
price: 20
},
{
name: "тыква",
price: 50
},
{
name: "уи",
price: 1000
}
];
const maxLengths = keys.slice().fill(0);
const normalizedInput = input.map(item => keys.reduce((acc, key, i) => {
const current = String(item[key]);
const currentLength = current.length;
if(currentLength > maxLengths[i])
maxLengths[i] = currentLength;
acc[key] = current;
acc.length += currentLength;
return acc;
}, { length: 0 }));
const maxLength = maxLengths.reduce(
(sum, current) => sum + current,
minGap
);
const res = normalizedInput
.map(({
name,
price,
length
}) => name + ' '.repeat(maxLength - length) + price)
.join('\n');