JSFiddle - React, Tailwind, and code Playground

by Amit Vishwakarma

HTML

<table class="sort">
        <caption>Census Data</caption>
        <tr>
            <th class="alpha">First Name:</th>
            <th class="alpha">Last Name:</th>
            <th class="date">Date of Birth:</th>
            <th class="numeric">Age:</th>
            <th class="alpha">Gender:</th>
        </tr>
        <tr>
            <td>Peter</td>
            <td>Parker</td>
            <td>12/23/1975</td>
            <td>36</td>
            <td>Male</td>
        </tr>
        <tr>
            <td>John</td>
            <td>Doe</td>
            <td>06/09/1982</td>
            <td>30</td>
            <td>Male</td>
        </tr>
    </table>

JavaScript

var resultArray = [];
    
    $(".sort tr").not(":first-child").each(function () {
        var innerArray = [];
     
        $(this).find('td').each(function () {
            innerArray.push($(this).text());
        });
    
        resultArray.push(innerArray);
        
        
alert(innerArray);
    });