So now we have the data out in Node JS line by line of each of the data cells in here.
But how can we know which one is the company name and which one is the contact still?
Because we just get them line by line.
So either we have to do something where we divide the index number here by 2 or 3, and we have to take
the modulus of it to find out if it's a company name or contact or country column.
I think it's a little simpler just to take it row by row and say that the first data cell is the company,
the second data cell is the contact, and the third one is the country.
So let's see how we can do that.
And let's try and test it out in the Chrome tools first before we move on to Node JS again.
So inside the Chrome browser, I'm going to press F12 to go back into our console.
So let's take this selector here.
And instead of also taking in the TD, we'll only go to the table row.
So we go like this.
And that's going to get the first table row here.
Now let's take a dot each loop again.
With the index element.
A arrow function and then we can do basically we go through each table row now.
So now we can find the table data cells inside this table row element so we can say something like console
log.
Dollar sign and then take the element and then we can say dot find to find all the children elements
and let's see how that looks.
Now it says it's not a function because I need to have jQuery enabled.
Let's try again.
And there we go.
So now it goes through each row of these table data rows.
So we have here, let me take this away here with the code.
So we have the second row here with three TD cells and the second one, the third row, fourth row,
last row and so on.
So it gets the the, the table data row for each row.
But let's see how we can print out just the first table data cell, the first column.
So in order to do that, we get basically a, we get with find, we get an array back.
If there's of all the children in this table row of a certain class in this case TD So we can try and
just take the first element in this array, which should be the company name for each of these children.
So now when I do that, we can see the first at table row is undefined with the TD because there is
no TD elements in the first row.
It is only a table header class or table header element.
The second one we get the Alfred Frudakis here and balloons, snap curve or whatever you say.
And then we have the the the other ones here all from one column only.
So that's pretty handy because we need to know, okay, which one is the company, which one is the
contact property, Which one is the country property.
So okay, now let's try and transfer this on to NodeJS.
So let's take this code we have here.
And I'm going to paste it inside of NodeJS.
I'm going to overwrite it with the other one we had actually.
So overwrite that.
So now we only go through to our.
And we just print the first element we see in this row.
So let's try and say no, let's save it first and let's say Node index.js see what we get here.
So now we get some weird output inside of the console right now because it's actually printing out or
this element that it's finding is the one we are returning in.
The array is actually a, a chario dom element, so it's printing out the whole Dom object of the index
side, the console.
It's not just the text or the HTML as we see in the Chrome tools, but it's easy to get around.
We just have to use the chario selector again.
So the dollar sign again and then wrap that around here.
And then again in the parent thesis and then say dot text.
So then we take this.
First we have the element, the table row.
We find the table or the table data cells.
The first one we select the first one with the zero index.
And then we take that and surround that with the stereo selector from this Dom element and get the text
from it.
So it's a little confusing because there's so there's a lot of parenthesis going around maybe for some
of you here.
So, but let's see what this outputs.
So there we go.
So now we get all of the table data cells for just the first column with the company name.
So now we easily know that this element right here.
Exactly.
Is the company name.
Okay, So let's try and make the code a little more readable now so we can do something like const DS
equals element, find, find all the children CD elements.
So that's going to make an array of these Dom elements.
And then we can simply say const company equals T DS or actually it's dollar sign.
See DS zero dot text.
Okay, so maybe that's a little easier to read.
Now let's try to do a console log of company name.
Okay, let's try and run Node Index.js and see if it's the same output.
And indeed it is the same output again.
So now we know for sure that we can get all of the company names inside of the inside of this table.
So now we just need to get the other column and it's going to be exactly the same approach.
Again, we just get the one index instead or the two index to get the country.
So now let's look in the next section on how to get the rest of the columns into our data and create
the nice data structure in JavaScript.