This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var obj = { 'key1': 'value1', 'key2': 'value2' }; | |
Object.keys(obj).forEach(function(key) { | |
var value = obj[key]; | |
console.log(key, value); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var state_info = { | |
'AL': {'lat': 32.3792233, 'lng': -86.3077368, 'capital': 'Montgomery'}, | |
'AK': {'lat': 58.3019444, 'lng': -134.4197221, 'capital': 'Juneau'}, | |
'AZ': {'lat': 33.4483771, 'lng': -112.0740373, 'capital': 'Phoenix'}, | |
'AR': {'lat': 34.7464809, 'lng': -92.28959479999999, 'capital': 'Little Rock'}, | |
'CA': {'lat': 38.5815719, 'lng': -121.4943996, 'capital': 'Sacramento'}, | |
'CO': {'lat': 39.7392358, 'lng': -104.990251, 'capital': 'Denver'}, | |
'CT': {'lat': 41.7658043, 'lng': -72.6733723, 'capital': 'Hartford'}, | |
'DE': {'lat': 39.158168, 'lng': -75.5243682, 'capital': 'Dover'}, | |
'FL': {'lat': 30.4382559, 'lng': -84.28073289999999, 'capital': 'Tallahassee'}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE if not exists store | |
( id serial, | |
sname varchar(40) not null, | |
qty integer not null, | |
price float not null, primary key (id)); | |
INSERT INTO store (sname, qty, price) | |
VALUES ('apple', 10, 1), ('pear', 5, 2), ('banana', 10, 1.5), ('lemon', 100, 0.1), ('orange', 50, 0.2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var db = require('../database'); | |
var app = express(); | |
module.exports = app; | |
app.get('/', function (request, response) { | |
// TODO: Initialize the query variable with a SQL query | |
// that returns all the rows in the ‘store’ table | |
var query = 'select * from store'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var db = require('../database'); | |
var app = express(); | |
module.exports = app; | |
app.get('/', function (request, response) { | |
// TODO: Initialize the query variable with a SQL query | |
// that returns all the rows in the ‘store’ table | |
var query = 'select * from store'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--Including Header partial--> | |
<%- include ../layouts/header.ejs %> | |
<% if (messages.error) { %> | |
<p style="color:red"><%- messages.error %></p> | |
<% } %> | |
<% if (messages.success) { %> | |
<p style="color:green"><%- messages.success %></p> | |
<% } %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var db = require('../database'); | |
var app = express(); | |
module.exports = app; | |
app.get('/', function (request, response) { | |
// TODO: Initialize the query variable with a SQL query | |
// that returns all the rows in the ‘store’ table | |
var query = 'select * from store'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Including Header Partial--> | |
<%- include ../layouts/header.ejs %> | |
<!-- Using if-check to see if an error occurred and displaying appropriate message--> | |
<% if (messages.error) { %> | |
<p style="color:red"><%- messages.error %></p> | |
<% } %> | |
<% if (messages.success) { %> | |
<p style="color:blue"><%- messages.success %></p> | |
<% } %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var db = require('../database'); | |
var app = express(); | |
module.exports = app; | |
app.get('/', function (request, response) { | |
// TODO: Initialize the query variable with a SQL query | |
// that returns all the rows in the ‘store’ table | |
var query = 'select * from store'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<!-- ‘title’ is the data that is passed from the index.js during the response.render function call --> | |
<title><%= title %></title> | |
</head> | |
<body> | |
<div> | |
<a href="/">Home</a> | | |
<a href="/store/add">Add item</a> | | |
<a href="/store">All items</a> |
NewerOlder