-
Notifications
You must be signed in to change notification settings - Fork 31
wk 1 node ecosystem assignment #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
charlottewest
wants to merge
2
commits into
pce-uw-jscript400:master
Choose a base branch
from
charlottewest:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| node_modules |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| const profile = require('./src/profile.js') | ||
| console.log(profile.age) | ||
| console.log(profile.name) | ||
|
|
||
| // const path = require('path') | ||
| // console.log(path.resolve()) | ||
|
|
||
| // const moment = require('moment') | ||
| // console.log(moment().format('MMMM Do YYYY, h:mm:ss a')) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| moment().format('MMMM Do YYYY, h:mm:ss a'); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "name": "w1-node-ecosystem", | ||
| "version": "1.0.0", | ||
| "description": "Welcome to JSCRIPT 400 - Server Side Development with JavaScript", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "start": "node index.js", | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/charlottewest/w1-node-ecosystem.git" | ||
| }, | ||
| "keywords": [], | ||
| "author": "", | ||
| "license": "ISC", | ||
| "bugs": { | ||
| "url": "https://github.com/charlottewest/w1-node-ecosystem/issues" | ||
| }, | ||
| "homepage": "https://github.com/charlottewest/w1-node-ecosystem#readme", | ||
| "dependencies": { | ||
| "moment": "^2.24.0" | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,71 +34,78 @@ $ npm -v | |
|
|
||
| ### Instructions & Guiding Questions | ||
|
|
||
| - [ ] Fork & Clone this repository | ||
| - [x] Fork & Clone this repository | ||
|
|
||
| * **Question:** What is the difference between forking and cloning a repository as opposed to just cloning a repository? | ||
|
|
||
| * **Your Answer:** | ||
|
|
||
| Forking is making a copy of a repository. After cloning your forked repo, any commits will be against the copy. Cloning a repository means that any commits will be against the original repo. | ||
| --- | ||
|
|
||
| - [ ] Run `npm init -y` from the command line | ||
| - [x] Run `npm init -y` from the command line | ||
|
|
||
| * **Question:** What does `npm init` do? How does the `-y` flag modify that command? | ||
|
|
||
| * **Your Answer:** | ||
|
|
||
| `npm init` created package.json file and then `-y` automatically filled out the contents (made some good assumptions) | ||
| --- | ||
|
|
||
| - [ ] Take a look at the file that was generated by the previous command | ||
| - [x] Take a look at the file that was generated by the previous command | ||
|
|
||
| * **Question:** What is the purpose of the following keys? "name", "scripts", "license" | ||
|
|
||
| * **Your Answer:** | ||
|
|
||
| name - name of the app/project, scripts - any scripts used to help run the app, license - it's a license! | ||
| --- | ||
|
|
||
| - [ ] Create a `.gitignore` file | ||
| - [x] Create a `.gitignore` file | ||
|
|
||
| * **Question:** What is the purpose of the `.gitignore` file? What is the significance of a "dot-file?" | ||
|
|
||
| * **Your Answer:** | ||
|
|
||
| A file that lists files that you want git to ignore. A dot file is a hidden file. | ||
| --- | ||
|
|
||
| - [ ] Create an `index.js` file with the following contents: `console.log('Hello, Node!')` | ||
| - [x] Create an `index.js` file with the following contents: `console.log('Hello, Node!')` | ||
|
|
||
| * **Question:** From the command line, how can you run this file? | ||
|
|
||
| * **Your Answer:** | ||
|
|
||
| `node index.js` | ||
| --- | ||
|
|
||
| - [ ] Run `npm test` from the command line | ||
| - [x] Run `npm test` from the command line | ||
|
|
||
| * **Question:** What happens and how is this related to what is in the `package.json` file? | ||
| * **Question:** What happens and how is this related to what is in the `package.json` file? | ||
|
|
||
| * **Your Answer:** | ||
|
|
||
| `> w1-node-ecosystem@1.0.0 test /Users/charlotte.west/js_cert/js-course-3/w1-node-ecosystem | ||
| > echo "Error: no test specified" && exit 1 | ||
|
|
||
| Error: no test specified | ||
| npm ERR! Test failed. See above for more details.` | ||
|
|
||
| The test script isn't set up in the scripts section of package.json. Whatever string is in the package.json script section will get run. In this case an echo command. | ||
| --- | ||
|
|
||
| - [ ] Create a new "script" command called "start" that has the following value: `node index.js` | ||
| - [x] Create a new "script" command called "start" that has the following value: `node index.js` | ||
|
|
||
| * **Question:** What will you enter on the command line to run that script? | ||
|
|
||
| * **Your Answer:** | ||
|
|
||
| `npm start` | ||
| --- | ||
|
|
||
| - [ ] Change the name of your "start" script to "my-file" | ||
| - [x] Change the name of your "start" script to "my-file" | ||
|
|
||
| * **Question:** The same pattern will not work to try and run this script. How can you successfully get this script to run? | ||
|
|
||
| * **Your Answer:** | ||
|
|
||
| `npm run my-file` | ||
| --- | ||
|
|
||
| - [ ] Create a new file called `profile.js`. Inside the file, copy the following but replace `<your-name>` with your name: | ||
| - [x] Create a new file called `profile.js`. Inside the file, copy the following but replace `<your-name>` with your name: | ||
| ```js | ||
| module.exports = '<your-name>' | ||
| ``` | ||
|
|
@@ -112,22 +119,24 @@ $ npm -v | |
| * **Question:** What gets logged? Why? | ||
|
|
||
| * **Your Answer:** | ||
| 'charlotte' - because we exported the string from the profile.js file and imported it into our index file. Then when we ran our start command (which runs the index.js file) it does what we asked it to do in profile.js | ||
|
|
||
| * **Question:** What is `module.exports` and what is its _type_ in JavaScript? What is `require` and what is its _type_ in JavaScript? | ||
|
|
||
| * **Your Answer:** | ||
|
|
||
| `module.exports` - | ||
| `require` - It's a function that takes a string that is a path to a file. | ||
| --- | ||
|
|
||
| - [ ] We can only export one thing from files when using Node. With that said, export both your name and your birthday from the `profile.js` file. | ||
| - [x] We can only export one thing from files when using Node. With that said, export both your name and your birthday from the `profile.js` file. | ||
|
|
||
| * **Question:** What are some ways you can solve this problem? | ||
|
|
||
| * **Your Answer:** | ||
|
|
||
| We can export both variables as an array | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is true, although more typically we'll export it as an object (i.e. |
||
| --- | ||
|
|
||
| - [ ] Add the following to your `index.js` file. Then, run your file. | ||
| - [x] Add the following to your `index.js` file. Then, run your file. | ||
| ```js | ||
| const path = require('path') | ||
| console.log(path.resolve()) | ||
|
|
@@ -136,28 +145,28 @@ $ npm -v | |
| * **Question:** What is `path` and where does it come from? | ||
|
|
||
| * **Your Answer:** | ||
|
|
||
| Path is a built in node module. | ||
| --- | ||
|
|
||
| - [ ] Install the [moment](https://www.npmjs.com/package/moment) package | ||
| - [x] Install the [moment](https://www.npmjs.com/package/moment) package | ||
|
|
||
| * **Question:** What command can you run to install this package? | ||
|
|
||
| * **Your Answer:** | ||
|
|
||
| `npm i moment` | ||
| --- | ||
|
|
||
| - [ ] On your own, use this package in the `index.js` file | ||
|
|
||
| * **Question:** Do you need to use a `./` to require the package? Why or why not? | ||
|
|
||
| * **Your Answer:** | ||
|
|
||
| Not if it's within the node_modules folder. Node will automatically check that folder. | ||
| --- | ||
|
|
||
| - [ ] Move your `profile.js` file into a `src/` folder. Update the path in your `index.js` file to ensure everything continues to work. | ||
| - [x] Move your `profile.js` file into a `src/` folder. Update the path in your `index.js` file to ensure everything continues to work. | ||
|
|
||
| #### Resources | ||
|
|
||
| - [Node.js Built-In Modules](https://nodejs.org/dist/latest-v12.x/docs/api/) | ||
| - [NPM: Moment](https://www.npmjs.com/package/moment) | ||
| - [NPM: Moment](https://www.npmjs.com/package/moment) | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| const name = 'charlotte west' | ||
| const age = 205 | ||
| module.exports = {name, age} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module.exportsis by default an object. Whatever you assign to it will be what is pulled in when yourequire()elsewhere.