JSFiddle - React, Tailwind, and code Playground

by lollero

HTML

<table>
    <tr>
        <td class="appendHere"></td>
        <td>Other stuff</td>
    </tr>
</table>

CSS

td { border: 1px dashed red; padding: 9px; }

JavaScript

var Names = {
        0: {
            firstname: 'John',
            lastname: 'Smith'
        },
        1: {
            firstname: 'Agent',
            lastname: 'Smith'
        },
        2: {
            firstname: 'Thomas',
            lastname: 'Anderson'
        }
    }
 
// Prepare to receive the names
var nameDump = '';

// Note that I changed the Names.length to a static number
for (var q = 0; q < 3; q++) {
    
    // Combine first and last name
    var name = Names[q].firstname + " " + Names[q].lastname;
    
    // Push names to nameDump with comma and space in between
    nameDump += name + ', ';
    
}

// Append all names inside on td
$('.appendHere').append( nameDump );