
Checkpoint
./server.js:617503/1313 ./public/client.js:617503/2375
Showing
2 changed files
with
18 additions
and
18 deletions
1 | // client-side js | 1 | application.togglePrettierEnabled()// client-side js |
2 | // run by the browser each time your view template is loaded | 2 | // run by the browser each time your view template is loaded |
3 | 3 | ||
4 | console.log('hello world :o'); | 4 | console.log("hello world :o"); |
5 | 5 | ||
6 | // our default array of dreams | 6 | // our default array of dreams |
7 | const dreams = [ | 7 | const dreams = [ |
8 | 'Find and count some sheep', | 8 | "Find and count some sheep", |
9 | 'Climb a really tall mountain', | 9 | "Climb a really tall mountain", |
10 | 'Wash the dishes' | 10 | "Wash the dishes" |
11 | ]; | 11 | ]; |
12 | 12 | ||
13 | // define variables that reference elements on our page | 13 | // define variables that reference elements on our page |
14 | const dreamsList = document.getElementById('dreams'); | 14 | const dreamsList = document.getElementById("dreams"); |
15 | const dreamsForm = document.forms[0]; | 15 | const dreamsForm = document.forms[0]; |
16 | const dreamInput = dreamsForm.elements['dream']; | 16 | const dreamInput = dreamsForm.elements["dream"]; |
17 | 17 | ||
18 | // a helper function that creates a list item for a given dream | 18 | // a helper function that creates a list item for a given dream |
19 | const appendNewDream = function(dream) { | 19 | const appendNewDream = function(dream) { |
20 | const newListItem = document.createElement('li'); | 20 | const newListItem = document.createElement("li"); |
21 | newListItem.innerHTML = dream; | 21 | newListItem.innerHTML = dream; |
22 | dreamsList.appendChild(newListItem); | 22 | dreamsList.appendChild(newListItem); |
23 | } | 23 | }; |
24 | 24 | ||
25 | // iterate through every dream and add it to our page | 25 | // iterate through every dream and add it to our page |
26 | dreams.forEach( function(dream) { | 26 | dreams.forEach(function(dream) { |
27 | appendNewDream(dream); | 27 | appendNewDream(dream); |
28 | }); | 28 | }); |
29 | 29 | ||
... | @@ -36,7 +36,7 @@ dreamsForm.onsubmit = function(event) { | ... | @@ -36,7 +36,7 @@ dreamsForm.onsubmit = function(event) { |
36 | dreams.push(dreamInput.value); | 36 | dreams.push(dreamInput.value); |
37 | appendNewDream(dreamInput.value); | 37 | appendNewDream(dreamInput.value); |
38 | 38 | ||
39 | // reset form | 39 | // reset form |
40 | dreamInput.value = ''; | 40 | dreamInput.value = ""; |
41 | dreamInput.focus(); | 41 | dreamInput.focus(); |
42 | }; | 42 | }; | ... | ... |
... | @@ -2,21 +2,21 @@ | ... | @@ -2,21 +2,21 @@ |
2 | // where your node app starts | 2 | // where your node app starts |
3 | 3 | ||
4 | // init project | 4 | // init project |
5 | const express = require('express'); | 5 | const express = require("express"); |
6 | const app = express(); | 6 | const app = express(); |
7 | 7 | ||
8 | // we've started you off with Express, | 8 | // we've started you off with Express, |
9 | // but feel free to use whatever libs or frameworks you'd like through `package.json`. | 9 | // but feel free to use whatever libs or frameworks you'd like through `package.json`. |
10 | 10 | ||
11 | // http://expressjs.com/en/starter/static-files.html | 11 | // http://expressjs.com/en/starter/static-files.html |
12 | app.use(express.static('public')); | 12 | app.use(express.static("public")); |
13 | 13 | ||
14 | // http://expressjs.com/en/starter/basic-routing.html | 14 | // http://expressjs.com/en/starter/basic-routing.html |
15 | app.get('/', function(request, response) { | 15 | app.get("/", function(request, response) { |
16 | response.sendFile(__dirname + '/views/index.html'); | 16 | response.sendFile(__dirname + "/views/index.html"); |
17 | }); | 17 | }); |
18 | 18 | ||
19 | // listen for requests :) | 19 | // listen for requests :) |
20 | const listener = app.listen(process.env.PORT, function() { | 20 | const listener = app.listen(process.env.PORT, function() { |
21 | console.log('Your app is listening on port ' + listener.address().port); | 21 | console.log("Your app is listening on port " + listener.address().port); |
22 | }); | 22 | }); | ... | ... |
-
Please register or sign in to post a comment