Git Product home page Git Product logo

js-from-dom-to-node's Introduction

Moving Away from the DOM

Congratulations! You are now able to understand how Javascript interacts with websites through the DOM. That's a big deal. Take a few seconds, breathe in, breathe out and realize that you now know something you didn't before. Only a few lessons ago, you didn't even know what the DOM was. Now you understand how to manipulate it.

Perspective

If you ever want to show your friends something cool, open up the console on any web page and then find the selector for an element, then modify it using Javascript in the console. Prepare to enjoy the shock and awe of your friends!

From DOM Manipulation to Programming Logic

For the rest of this material, we will be moving from the basics of DOM manipulation to the meat and potatoes of programming. This means we are going to cover the ideas of conditionals, looping, encapsulation and syntax. I know those may not be familiar to you, but over the next few lessons they will become second nature! Remember when DOM was a scary word? Encapsulation will soon go the way of the DOM. You're going to be encapsulating everything.

Really the goal of the rest of this course is to introduce you to programmatic thinking. We will be doing that through explaining Javascript, but the goal is for every student to begin using programmatic thinking as a general way to solve problems. These problems may be creating the next Facebook, or it may be just solving the best order to complete your errands. You'll notice programmatic, logical thinking starting to permeate throughout your decision process. It's incredibly powerful and something that has aided millions of programmers to solve some of the hardest problems in the world.

That is the goal with this class. While we may touch on making pictures of cats spin, we want you to internalize the thought process required to solve that silly problem. Hopefully, you'll go off after this class and solve some slightly more important problems :)

Javascript Outside of the Browser

You've spent some time in the browser with Javascript. That's great. Now let's get to where Javascript has been rapidly increasing its programming market share: outside of the browser. You may have heard of it, but a new tool called NodeJS was created a few years back to allow developers to write Javascript code outside of the browser. That is what we are going to use now to be able to go deep on programmatic thinking, without having to explain complicated browser interactions. We want to simplify programming down to its most core elements.

Hello World

Let's write your first code using NodeJS and non-browser Javascript. To do this, we are going to remove your first set of training wheels. We are no longer going to be using the CodePens that we've been using before. We are going to use a real developer environment through the Learn IDE.

Training Wheels

The Learn IDE is available as both an in-browser development environment as well as a standalone application.

To choose which environment you would like to work in, on any learn.co page, click your user image in the upper right corner of the page, then click 'Manage Account.'

manage account menu

In Account Management, click 'Learning Environment' and choose either 'IDE In Browser' or 'IDE Download.' Or, if you are already comfortable using an IDE and a console and prefer your own set up, you may also choose 'Local.' This lesson's instructions assume that you are using the Learn IDE in browser.

If you choose 'IDE In Browser' you are set and can navigate back to this lesson. If you have chosen 'IDE Download,' you can download and set up the IDE here.

Now, click "Open IDE" to open your environment. On the left side is your file tree. In the js-from-dom-to-node folder, click index.js to open the file up. IT'S CODING TIME.

Running Code in Chrome's Browser Console

First thing is first, I want to show you that everything we will do in the IDE, you can do in the console. In your browser, right click and select Inspect. Select the Console tab, type console.log("Hello, World!"), and press Enter. You should see "Hello, World!" printed right below your line of code. Congrats! You just wrote your first line of browser-less code. All this does is print out whatever is in between the parenthesis.

Let's bring that code over to our index.js file on the IDE. Make sure you are editing the index.js file, which is inside a folder, js, inside the js-from-dom-to-node folder. Once in there go ahead and paste the following code in there:

console.log('Hello, World!');

Now when you hit Enter, nothing super interesting will happen. All that occurs is the cursor moves to a new line. That's because you are in the text editor. This is pretty much the same as using Word. To get this to actually return something like we did in the Console in the browser we need to execute the index.js file. It sounds super official, but all we are going to do is tell the IDE "I'm ready, run this code and show me the result".

First, we have to save the file. Next, look at the pane at the bottom of the IDE. This is your terminal. Below your code you should see a flashing cursor like this:

command line in ide

Alright, let's let the magic happen! First, we need to make sure we are in the right folder. Our goal is to make it into the "js-from-dom-to-node" folder. If you look at the text next to the time, you should see js-from-dom-to-node or something very similar. If you see that, you are good and you can skip the next section. If it says something else, follow these instructions:

If you see code, we need to go into our labs folder first. To do this type cd labs. Now if should see labs next to the clock. We have to go one more folder in. I know this by looking at the folder structure on the left. See how labs is in code and js-from-dom-to-node is in labs? Ok now we need to cd into the js-from-dom-to-node lab. Take a look at your folder structure on the right to get the exact name and then type cd EXACT-FOLDER-YOU-WANT-TO-ENTER. In my case, I get js-from-dom-to-node. If you were successful, you'll see js-from-dom-to-node next to the clock.

Running Code With Node

To run your code, in your terminal, you can type node index.js. node is the node code runner and index.js is the name of your file. You should see:

Hello, World!

Woot! It worked. You just wrote your first Javascript outside of the browser. Now let's submit it back to Learn. In your terminal type learn submit. This will send your code up to Learn and you may move on to the next lesson.

If you would like to try a few more examples, take a look at the two JavaScript files inside more_js. From your current directory, run node more_js/example_one.js and node more_js/example_two.js to see them in action.

Possible Errors

After you type in node index.js you get something looks like:

module.js:471
    throw err;
    ^

Error: Cannot find module '/home/jmburges/code/labs/index.js'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:393:7)
    at startup (bootstrap_node.js:150:9)
    at bootstrap_node.js:508:3

The key there is "Error: Cannot find module". That just means you are in the wrong folder. Go back and read the earlier paragraph that starts "If you see code...". That should help you out. You need to be seeing js-from-dom-to-node next to the clock.

js-from-dom-to-node's People

Contributors

gj avatar jmburges avatar krystin987 avatar maxwellbenton avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

js-from-dom-to-node's Issues

nodejs index.js

when I type in nodejs index.js
to execute the index.js file nothing is happening for me. It looks like im in the right lab and the console.log("Hello World!") is in the text editor not in the cosole

IDE Unavailable

I have checked my browser settings and the IDE should be appealing but all I have access to is the sandbox. Any thoughts? Thanks!

Error while doing learn submit

`learn submit
Adding changes...
Committing changes...
Pushing changes to GitHub...
Submitting lesson...

/usr/local/rvm/gems/ruby-2.3.1/gems/learn-submit-1.3.1/lib/learn_submit/submission.rb:152:in submit!': undefined method match' for nil:NilClass (NoMethodError)
Did you mean? catch
from /usr/local/rvm/gems/ruby-2.3.1/gems/learn-submit-1.3.1/lib/learn_submit/submission.rb:148:in submit!' from /usr/local/rvm/gems/ruby-2.3.1/gems/learn-submit-1.3.1/lib/learn_submit/submission.rb:29:in create'
from /usr/local/rvm/gems/ruby-2.3.1/gems/learn-submit-1.3.1/lib/learn_submit/submission.rb:9:in create' from /usr/local/rvm/gems/ruby-2.3.1/gems/learn-submit-1.3.1/bin/learn-submit:15:in <top (required)>'
from /usr/local/rvm/gems/ruby-2.3.1/bin/learn-submit:23:in load' from /usr/local/rvm/gems/ruby-2.3.1/bin/learn-submit:23:in

'`

Issue opening the IDE

I do not have the button at the top of the screen to open the IDE, I am only able to open the sandbox

nothing after adding console.log("happy, world!");

as expected

First, we have to save the file. Next, look at the pane at the bottom of the IDE. This is your terminal. Below your code you should see a flashing cursor like this:

well, i dont see it. i've been trying to figure this out all day.

Having trouble pushing to the repo - Git::GitExecuteError

I cannot push to the repo. It says that it doesn't have the permission. I saw that Jeff Dugan had a similar issue but it didn't help me. I even set up the SSH key by instructions, and still no luck ๐Ÿ˜’

it denied to learn-ide-user. (Git::GitExecuteError) fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

Also, I checked at the GitHub website, the repo exists.

typo

hello!
this line
", breathe in, breath out and realize"
should be
", breathe in, breathe out and realize"

No Open IDE Button, No Labs folder

Like others have mentioned, there's no Open IDE button.

Tried to manually do it. I forked it over from github, it saved onto my computer. But when it opens, it always opens up "Sandbox" instead. When I looked for the files on my computer, it exists there and I have to manually open the index.js by right clicking and open Learn. I tried following the instructions on this page, but then had an error message regarding the file path location.

Tried to trouble shoot by following these instructions that are on the lesson:
"If you see code, we need to go into our labs folder first. To do this type cd labs. Now if should see labs next to the clock. We have to go one more folder in. I know this by looking at the folder structure on the left. See how labs is in code and js-from-dom-to-node is in labs?..."

There's a problem with the above because no where does a "code" or "labs" folders even exist on my computer yet. No are there any specific instructions how or where we should put those folders.

saving the file

I tried running the code it wouldn't work until i thought about and i realized that i didn't save the file.
So basically i was telling it to run an empty file i think you should add that to the instructions

lesson not found

I'm unable to open the lesson in the IDE, both through the web and Atom. The folder 'js-from-dom-to-node-bootcamp-prep-000' is empty, and I get an error saying something went wrong. I have gone back and checked I did the set-up correctly (as far as I can tell), and have the correct packages installed on Atom. but when I tried to open the IDE I was presented with the same message.
Screenshot (20)

won't work

Hi :)

Near my time clock it says "js-from-dome-to-node" but it still keeps showing an error I am not sure why... I saved the index.js file and then went thru the steps but it still says it ...any tips

Nodejs index.js

Hello. I am trying to execute the command console.log("Hello, World!") by typing, as instructed, nodejs index.js. I am in the correct folder, titled "js-from-dom-to-node-bootcamp-prep-100" and in the index.js subfolder. When I try to execute, nothing happens. Am I missing something?

IDE not working

I get the cannot find module message after typing node index.js. So as the lab said I tried to cd into labs, however, when I do that I get a message saying no such file or directory exists. I'm just wondering where I go from here because unfortunately I'm kind of stuck.

Issue

I cannot download the files for this lesson. They are not there on the page.

Unable to fork lesson

I keep getting this error:

Looking for lesson...
Forking lesson...
Cloning lesson...
There was a problem cloning this lesson. Retrying...
Cloning lesson...
There was a problem cloning this lesson. Retrying...
Cloning lesson...
Cloning lesson...
Cannot clone this lesson right now. Please try again.

Do you have suggestions?

Learn.CO app not working

When typing the console.log("Hello, World!") request in the top line. When you go to the bottom and type nodejs index.js. Nothing happens. I have rebooted and also have restarted the web app but had no success. Please advise.

"Cannot clone this lesson right now"

I'm using the latest version of Chrome and the in-browser IDE. When I try to load the lesson, it gets stuck on the cloning the lesson part.

I used the Ask a question on the sidebar and had a Zoom conversation with technical support and they couldn't figure out how to make it work. Is this a problem on my end?

I think this is a curriculum issue seeing as though I can't progress in the curriculum until this is resolved.

What can I do to progress in the lessons? Thanks for your help.

Screen Shot 2019-12-07 at 9 39 59 PM

Known Issue

Problem: This lesson's imagery is outdated, using the old IDE. Could have improved instructions around working with different environments.

Lab references pressing OPEN IDE but there is no button

This lab says:

To launch the Learn IDE, click the blue Open button at the top of this page. This should download the lesson to your IDE and open the IDE. If you need to re-download the IDE, you can do so here.

But there is no button, only for the sandbox.

problem with the learn submit part

Adding changes...
Committing changes...
It looks like you have no changes to commit. Will still try updating your submission...
Pushing changes to GitHub...
/usr/local/rvm/gems/ruby-2.3.1/gems/git-1.3.0/lib/git/lib.rb:937:in command': git '--git-dir=/home/darkess782-103554/code/labs/js-from-dom-to-node-bootcamp-prep-000/.git' '--work-tree=/home/darkess782-103554/cod (Git::GitExecuteError)ode-bootcamp-prep-000' push 'origin' 'master' 2>&1:Warning: Permanently added the RSA host key for IP address '192.30.255.112' to the list of known hosts. ERROR: Permission to darkess78/js-from-dom-to-node-bootcamp-prep-000.git denied to learn-ide-user. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. from /usr/local/rvm/gems/ruby-2.3.1/gems/git-1.3.0/lib/git/lib.rb:742:in push'
from /usr/local/rvm/gems/ruby-2.3.1/gems/git-1.3.0/lib/git/base.rb:329:in push' from /usr/local/rvm/gems/ruby-2.3.1/gems/learn-submit-1.3.0/lib/learn_submit/submission/git_interactor.rb:133:in block in push!'
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/timeout.rb:91:in block in timeout' from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/timeout.rb:33:in block in catch'
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/timeout.rb:33:in catch' from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/timeout.rb:33:in catch'
from /usr/local/rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/timeout.rb:106:in timeout' from /usr/local/rvm/gems/ruby-2.3.1/gems/learn-submit-1.3.0/lib/learn_submit/submission/git_interactor.rb:132:in push!'
from /usr/local/rvm/gems/ruby-2.3.1/gems/learn-submit-1.3.0/lib/learn_submit/submission/git_interactor.rb:23:in commit_and_push' from /usr/local/rvm/gems/ruby-2.3.1/gems/learn-submit-1.3.0/lib/learn_submit/submission.rb:100:in commit_and_push!'
from /usr/local/rvm/gems/ruby-2.3.1/gems/learn-submit-1.3.0/lib/learn_submit/submission.rb:26:in create' from /usr/local/rvm/gems/ruby-2.3.1/gems/learn-submit-1.3.0/lib/learn_submit/submission.rb:9:in create'
from /usr/local/rvm/gems/ruby-2.3.1/gems/learn-submit-1.3.0/bin/learn-submit:15:in <top (required)>' from /usr/local/rvm/gems/ruby-2.3.1/bin/learn-submit:23:in load'
from /usr/local/rvm/gems/ruby-2.3.1/bin/learn-submit:23:in <main>' from /usr/local/rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in eval'
from /usr/local/rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `

'

Incomplete Instructions

This page does not inform new users (how) to use the "learn submit" command required to complete the lab.

Opening Project

Hi!

Im unable to open the project required to continue the course. I have IDE 3 downloaded and Atom as well but at the top of the page, "sandbox" is the only option given to me when it doesn't offer the js file.

Thank you.

Grammar/clarity issue

The wording of the line "but the goal of every student we serve at The Flatiron School is to teach programmatic thinking as a general way to solve problems." implies that this is the student's goal. I think what you're trying to say is something like "teaching programmatic thinking to every student is the goal of the school". The goal of the student, as such, is to learn (of course).

Learn IDE not offering any option to save

I'm in the first lesson of using the IDE and it's not even giving me an option to save index.js and run it. It runs perfectly, but the console doesn't display anything. When I type in Learn Submit, it says no changes have been made. Thanks for your help in advance.

IDE blue button

after multiple tries of making sure my IDE in the settings was set to browser I still couldn't get the IDE button.

IDE Error

Browser IDE can't load Lab. I try to refresh the pages seven times but nothing. I am using chrome.
Capture

IDE Not Loading

Hi, when I open the IDE in my Chrome browser the files are not displayed and I am unable to type into the terminal. Basically, the IDE opens up and I am in the folder "first-ide-lab-ghe-compat-bootcamp-prep-001" and am able to type in the text editor only. I've tried reading a little on why this may be but haven't found a solution yet. Any help is much appreciated. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.