All right. So here's the answer to challenge 1
12. We've deleted the console log inside our root route and instead we want to be able to log this array 2
called posts inside our home.ejs so that when we create a new post through the compose page then 3
once we get back onto the home page, we should be able to log that new post as well as any others that 4
we've created previously. In order to do this 5
we first have to pass over this posts array into the home.ejs page when we render it. In order to do that 6
we need to add another key value pair to this 7
essentially what is a Javascript object 8
right? 9
Let's add a comma after that one 10
and then let's add our second object. 11
And I'm just going to reformat this so that you can see it a bit more clearly. 12
So the first object has a key of startingContent and a value of homeStartingContent which comes from 13
here. 14
The second object I'm going to call posts and I'm also going to pass over the posts array which comes 15
from over here. 16
So that means that once I render the home.ejs page I should have access to something called posts 17
which should be the array of posts that I've created so far. Inside the home.ejs, all we need to do 18
is to console.og that posts array. And remember that this won't work unless we add those EJS scriptlet 19
tags which look like this. 20
And remember that even small things such as curly braces or just a single closing curly brace also need 21
these scriptlet tags for them to work. 22
So let's go ahead and wrap this line of Javascript inside some EJS scriptlet tags which is an angle 23
bracket, percentage sign and then we're going to close it off with again percentage angle bracket. 24
So now if we hit save and we head back to our home page and we go over to the compose screen and we 25
just compose some sort of post, hit publish and we get redirected back to the home. 26
ejs at which point we should have passed over that posts array. 27
So now if we check our console you can see that logged in here is the same post that we composed earlier 28
on 29
but in this case it's actually being logged from within our home. 30
ejs.