Okay, one.
So right now we have the job description that we can select and print out.
We also have the job title.
We can select it and print it out.
But remember before in the other section about data structure, I talked about that we wanted to have
an array of objects.
So let's look at about.
So let's look on how to get this array of objects and we'll return that.
So instead of doing two dot each loops, we're going to just do one dot map loop instead.
And this dot map loop is going to return the array of objects with all the different properties.
So I can go ahead and test out, write some code, then I can paste it inside the Chrome developer console
to test out if it works in a fast and easy way compared to running the chromium browser first.
So let's see how we can do this.
Remember that the result of the job title and the job URL is inside the same element.
So we're just going to do one loop and get two properties in one, two for one.
So result title and then we're going to use a dot map instead.
And it has the same arguments, the index and the element.
And then we use a curly brace here because we're going to do a little magic here.
We're going to say const.
And title and well, when I say we're going to do a little magic here, I mean that we're going to do
multiple statements rather than just return one statement, then you can omit the curly braces.
But since we're going to do several things inside the function, we need to use the curly braces.
So a little further explanation than just saying magic.
Anyway, then we say the jQuery selector dot text to get the title.
And URL is.
Element attribute href.
We already done that before.
Now we just need to return a new object.
So we say return and then have the curly braces for returning a JavaScript object.
Then we put in a title the property of the title and then the URL.
That's going to return an array of objects.
Let's also make sure that we have this const results array that we're returning here from this dot map
function.
So that's going to return this array of objects with the different properties.
So let's say console log results just to check if we got all of the elements.
Now, since I just want to check quickly.
If it works, I can put it inside the Chrome developer console just to check if my code works very fast
and I can see I get an array of different objects and if I look inside it.
I can see that number zero has a title and a URL, so it all looks good.
And now we're going to run it inside the NodeJS project and see if it works.
So Node Index.js.
Now the page has loaded and.
I can see lots of console printouts and something else.
So I'm just going to delete the old each loops we have before because we're not going to use them anymore.
They're just.
Uh, not being used now.
We're only going to do one loop instead.
So let's close the browser here and then let's run it again.
And this is why I like to test things out inside Chrome developer console, because you can just test
it out really fast in the console compared to when it has to load out the browser first.
Anyway.
Now, as you can see, it's returning this weird output with some something about root and objects and
circular.
Lots of interesting things.
And what is what is actually returning is an array of different cherry objects.
There is one difference between Cheerio and jQuery, which always gets me for some reason, which is
that you have to use a dot get.
When you use a dot map function inside of NodeJS you.
Compared to when you're inside jQuery, inside the browser.
You don't have to do that.
You can simply get away with just doing something like this.
But if you're inside Node JS, which aerial, you have to make sure to have a dot get when you're using
a map function.
Then you're going to get the values of the actual array.
And now if I run it inside the console again or inside Node JS again, I can see that we should be getting
the values of the different objects instead instead of these chario objects.
So there we go.
Now I'm getting all of the titles and URLs in this array instead.
And now we're absolutely sure that each title and URL fits one another.
There hasn't been any skips in the loops or something like that.
So now on to the next section.
We're going to get some more properties into our array and find the date the job was posted.