Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js loop array

// CustomerSearchResults.tsx

import * as React from "react";
import Customer from "./Customer";

interface CustomerSearchResultsProps {
  customers: Customer[];
}

const CustomerSearchResults = (props: CustomerSearchResultsProps) => {
  const rows = props.customers.map(customer => (
    <tr key={customer.id}>
      <th>{customer.id}</th>
      <td>{customer.name}</td>
      <td>{customer.revenue}</td>
      <td>{customer.firstSale.toString()}</td>
    </tr>
  ));

  return (
    <table className="table table-hover">
      <thead>
        <tr>
          <th>Id</th>
          <th>Name</th>
          <th>Revenue</th>
          <th>First Sale</th>
        </tr>
      </thead>
      <tbody>{rows}</tbody>
    </table>
  );
};

export default CustomerSearchResults;
Source by www.carlrippon.com #
 
PREVIOUS NEXT
Tagged: #js #loop #array
ADD COMMENT
Topic
Name
1+8 =