WEBVTT 0 00:00.240 --> 00:00.570 All right. 1 00:00.570 --> 00:03.630 So here comes the answer to challenge 1. 2 00:03.750 --> 00:08.730 If you've already completed challenge 1 and you just want to see how it's done then continue watching 3 00:08.730 --> 00:09.500 the video. 4 00:09.840 --> 00:14.820 If you've gone through all of the hints and you're still stuck and you really don't know what to do 5 00:15.150 --> 00:18.420 then also keep playing and I'll show you the answer. 6 00:18.450 --> 00:24.460 But if you still want to keep trying then pause the video before I reveal the answer. 7 00:24.480 --> 00:25.470 All right here we go. 8 00:25.650 --> 00:27.050 So inside our home. 9 00:27.220 --> 00:27.610 ejs, 10 00:27.630 --> 00:33.510 we're going to create that h1 that just says home. And then we're going to go into our app.js 11 00:33.810 --> 00:37.130 which is our server code to try and render that page. 12 00:37.320 --> 00:40.760 And the route that we're going to target is going to be the home route. 13 00:40.830 --> 00:46.440 So we're going to say app.get and we're going to target the home route or the root route. 14 00:46.530 --> 00:48.590 That's the one that's just the /. 15 00:48.710 --> 00:55.140 And then we're going to put in a callback function with our req and res as per usual. 16 00:55.560 --> 01:00.790 And then inside this function is where we're going to render our home.ejs. 17 01:00.900 --> 01:08.790 And if you remember the method for that using Express is res.render and then we specify what it is 18 01:08.790 --> 01:10.070 that we want to render. 19 01:10.230 --> 01:16.830 And remember the page that we want to render has to be something.ejs and it has to be inside a folder 20 01:16.830 --> 01:20.800 called views in the root of our main project folder 21 01:21.120 --> 01:25.550 in the same hierarchical level as app.js. 22 01:25.740 --> 01:29.230 Now the page that we want to render in this case is home.ejs 23 01:29.370 --> 01:37.140 so all we have to specify is the string home inside a set of quotation marks. And then we'll close everything 24 01:37.140 --> 01:39.180 off with some semi-colons. 25 01:39.180 --> 01:46.230 So now if we hit Save and we make sure that we're inside our ejs-challenge folder then we're going 26 01:46.230 --> 01:54.020 to use nodemon to start our app.js and run our server. So service starts on port 3000 27 01:54.090 --> 01:56.700 I'm going to head over to localhost:3000 28 01:56.970 --> 02:02.530 and this is how we achieve the goal for Challenge 1. 29 02:02.540 --> 02:07.280 Now if you manage to get here without needing any of the hints then that's a huge pat on the back and 30 02:07.280 --> 02:08.710 a gold star for you. 31 02:08.960 --> 02:13.460 Now if you needed to have a look at a few of the hints then that's fine as well. 32 02:13.460 --> 02:19.860 See if in the coming challenges you can reduce the number of hints you need and rely more on Sstack Overflow 33 02:19.860 --> 02:25.910 or Google to achieve what it is that you want instead of looking at the hints or the answers. And only 34 02:25.910 --> 02:31.690 use them when you're well and truly stuck and you can't move forwards without watching a hint or two. 35 02:31.880 --> 02:37.140 So that's all for challenge 1. In the next video we're going to head over to the next challenge.