Javascript get entire 2nd column

I have searched for a solution to this issue everywhere but nothing has worked. I have successfully pulled the first column but I am unable to pull the 2nd column. The following code pulls the entire 1st column successfully.

I changed

.cells

to

[1]

and it pulls nothing. I have tried

:nth-child(1)

but that doesn't work either. I feel I am missing something very trivial. Any help is very much appreciated.

First and foremost. Never ever use l (lower case el) as a variable. It is far to similar to 1 (one). Also be careful with upper case "o", and upper-case "i". Lowercase "o" is also often disliked.

It might look OK now, but when you review it in 6 months or a year, perhaps not so much. Also consider others might have to both read and modify your code.

Enough about that.

Your code, as it is, should work. If you do not get the desired result then the problem is elsewhere.

Make it reusable

However, to simplify the code and make it easier to re-use, you can add a parameter for id of the table as well as desired column. Resulting function could be something like this, with some extra checks:

Use Array:

If you are going to use the cells one by one the best approach would be to return an Array instead of a string. Then you can loop the array, or if you want it as a string simply join it with desired delimiter. This would most likely be the most useful and reusable function.

Demo:

Speed.

If your table cells does not contain any <script> or <style>, which they should not, you can also consider using textContent over innerText. Especially if table is large. It is a much faster. Here is a short article on the subject from Kelly Norton: