Giter Site home page Giter Site logo

js-node-practice-lab-bootcamp-prep-000's Introduction

Strings and Numbers Outside of the Browser

In our effort to familiarize ourselves with the Learn IDE, Let's play with strings and numbers again but in the Learn IDE. First things first though, let's open this lab in the Learn IDE. Go ahead and click the blue "Open" button at the top of this page. You should then be whisked away to the IDE.

Alright! This lab is very important. I'm going to teach you how to approach all labs...and really everything in coding. That's a huge statement, but programming is actually fairly simple if you follow this process.

First things first, let's run the code we are given. That should always be your first task. Just like when you are using a map to find a new restaurant, you need to know where you are now before you can know where you need to go. The JavaScript file we'll be workign with is located inside a js folder in this lesson. To run the code, type node js/index.js in your terminal. You should get something like this:

Name: Joe;
Height: 74;

Look familiar? Open up the index.js file inside the js folder and take a look. No HTML here, but you can see some basic things. The first two lines of code are below:

var name = 'Joe';
var height = '74';

These two just assign the value "Joe" and "74" to name and height, respectively. name and height are variables. "Joe" and "74" are Strings. We know they are Strings because they are wrapped in quotes. The next four lines do all of the outputting to your terminal.

console.log('Name:');
console.log(name);

console.log('Height:');
console.log(height);

The first two at first print the String "Name:", then it prints the value inside name. Earlier in our program, we assigned name a value of "Joe". So, it prints out Joe. Nice! What if we put name in quotes?. Give it a try, then run your program again by typing node js/index.js. You should see it print out the literal name instead of Joe. You just converted name from a variable into a String. Remove the quotes and everything will work again.

Ok, go ahead and change the name variable to your name. To do this, modify the first line to something like this var name = "Janet". Re-run your code and you'll see everything gets updated. Awesome.

Finally, we are going to modify our height. You could modify the height the same way we modified name. Simply change the "74" to whatever your height is. Remember last time though? We wanted to just have you "grow" by adding 1 to our current height. We can try that out by modifying the console.log(height) line by writing console.log(height+1). If you re-run that code you'll see it just appends 1 to the end of whatever height you had. That's not what we want! We want proper addition to occur. Just like last time, we need to translate our String ("74") into a number. You can do this in your console.log like this: console.log(parseInt(height) + 1 ). That converts "74" into a number and then adds one. If you re-run the code now you'll see that it works! The other way we can modify this is to change the assignment of the variable in the first place. So let's modify the var height = "74" line to look like this

var height = 74;

Boom! We took away the quotes and now it's a number not a string. You can remove the parseInt part of your console.log to look like this: console.log(height + 1) and everything should work properly.

Now it's time to submit your work back to learn. Go ahead and run learn submit in the terminal. You should then get a few more green lights and be ready to move on to the next lesson. Congratulations

View Node Practice on Learn.co and start learning to code for free.

js-node-practice-lab-bootcamp-prep-000's People

Contributors

cdcardle avatar gj avatar jmburges avatar maxwellbenton avatar mel510 avatar russwoods avatar

Stargazers

 avatar

Watchers

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

js-node-practice-lab-bootcamp-prep-000's Issues

No specs in lab

The learn function returns the error:
"This directory doesn't appear to have any specs in it"

One must commit (learn submit) without testing first.

1

Bootcamp prep "node" fork problem

screen shot 2018-10-16 at 9 55 14 pm

Problem 1: There is a problem with ide3 app. So there is no "blue open tab" button to do this. It's replaced by the blue sandbox tab. I would have to open up the ide3 separately.

Problem 2: I forked, cloned ssh, go into ide3, in the terminal i write "git clone (ssh code). When I come back to the lesson, the fork option is not completed after all the steps. I can't proceed onto to the next step because of this.

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.