Heading1 Heading2
FoooBar 23
FoBar 5
FooooBar 12
In above example, I want the numbers 23 5 and 12 always to be in a line irrespective of the length of first column values. The values in second column should be aligned. How do I do this in Javascript?
I solved this like
function pad(pad, str, padRight) {
let difference = pad - str.length;
let exactTab = Math.ceil(difference / 4);
console.log(exactTab);
if (typeof str === 'undefined')
return pad;
if (padRight) {
return Array(exactTab).join('\t');
} else {
return (str + difference).substring(0, pad.length);
}
}