Title: how to pass data from table diagonal React JS
Tags: javascript;html;reactjs;ecmascript-6;react-hooks
Question: I'm currently trying to pass an array to the data table from diagonal.

but here i pass the data using hardcoded values.
```import { useState } from &quot;react&quot;;


//const rawData= [[7,0,0,1,6,1],[8,2,5,1,7],[5,4,1,4],[2,2,0]]

export default function DataTable1(){
    //const [tableData, setTableData] = useState(rawData)

    return(
        <table&gt;
        <thead&gt;
            <tr&gt;
                <th&gt;</th&gt;
                <th&gt;Week 1</th&gt;
                <th&gt;Week 2</th&gt;
                <th&gt;Week 3</th&gt;
                <th&gt;Week 4</th&gt;
                <th&gt;Net Lost</th&gt;
                <th&gt;Net Recovered</th&gt;
            </tr&gt;
        </thead&gt;
        <tbody&gt;
            <tr&gt;
                <th&gt;Week 1</th&gt;
                <td&gt;7</td&gt;
                <td&gt;0</td&gt;
                <td&gt;0</td&gt;
                <td&gt;1</td&gt;
                <td&gt;6</td&gt;
                <td&gt;1</td&gt;
                
            </tr&gt;
            <tr&gt;
                <th&gt;Week 2</th&gt;
                <td&gt;</td&gt;
                <td&gt;8</td&gt;
                <td&gt;2</td&gt;
                <td&gt;5</td&gt;
                <td&gt;1</td&gt;
                <td&gt;7</td&gt;
            </tr&gt;
            <tr&gt;
                <th&gt;Week 3</th&gt;
                <td&gt;</td&gt;
                <td&gt;</td&gt;
                <td&gt;5</td&gt;
                <td&gt;4</td&gt;
                <td&gt;1</td&gt;
                <td&gt;4</td&gt;
            </tr&gt;
            <tr&gt;
                <th&gt;Week 4</th&gt;
                <td&gt;</td&gt;
                <td&gt;</td&gt;
                <td&gt;</td&gt;
                <td&gt;2</td&gt;
                <td&gt;2</td&gt;
                <td&gt;0</td&gt;
            </tr&gt;


        </tbody&gt;
    </table&gt;
        
    )
}
```
But instead of hard coded values, i need to use the ```rawData``` array to fill the table. is there any way to fill the rawData array's values from the diagonal?
Can someone give me the paths and suggestions to get the desired output using the array?
what i tried:
```<td&gt;rawData[0][0]</td&gt;
```
I tried to fill using the above way. but it didn't work and felt that its not the right way to do it


Here is the accepted answer: Try this
``` import { useState } from &quot;react&quot;;

 export default function DataTable1(){

 const rawData= [[7,0,0,1,6,1],[8,2,5,1,7],[5,4,1,4],[2,2,0]]
 
 return (
    <table&gt;
      <thead&gt;
        <tr&gt;
          <th&gt;</th&gt;
          <th&gt;Week 1</th&gt;
          <th&gt;Week 2</th&gt;
          <th&gt;Week 3</th&gt;
          <th&gt;Week 4</th&gt;
          <th&gt;Net Lost</th&gt;
          <th&gt;Net Recovered</th&gt;
        </tr&gt;
      </thead&gt;
      <tbody&gt;
        {rawData.map((item, index) =&gt; {
          return (
            <tr&gt;
              <th&gt;Week {index + 1}</th&gt;
              {[...Array(6 - item.length)].map((item) =&gt; {
                return <td&gt;</td&gt;;  //for empty values
              })}
              {item.map((itm) =&gt; {
                return <td&gt;{itm}</td&gt;;
              })}
            </tr&gt;
          );
        })}
      </tbody&gt;
    </table&gt;
  );
   
}
```

Comment for this answer: man Is it that simple....You saved me...Thanks a lot mate...
Comment for this answer: can you please explain code under the 
Comment for this answer: check react doc: https://reactjs.org/docs/lists-and-keys.html. You will get to know


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2022:00:09/15/22', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><html><reactjs><ecmascript-6><react-hooks>', 'Title': 'how to pass data from table diagonal React JS', 'ViewCount': 35, 'id': 73735016, 'user_AboutMe': '', 'user_AccountId': 25493114.0, 'user_DisplayName': 'Deric', 'user_Reputation': 63.0, 'user_Views': 11.0, 'user_id': 19287552.0}}