Skip to content

Latest commit

 

History

History
49 lines (25 loc) · 3.45 KB

README.md

File metadata and controls

49 lines (25 loc) · 3.45 KB

scratch-pad.github.io

Scratch Pad

Practice the basics of JavaScript by passing unit tests.


Getting Started

  • It's important that you do not move, or change the name of, any files in these directories. If you do the tests we have written may not work, and you will have a lot of problems we'll have to solve!

  • Inside the Scratch-Pad directory you should have several folders prefixed with day-x. Each of these folders correspond to one of the four days we will work on Scratch-Pad, with the x representing the specific day. If you open up day-1 you will see that we have a homework directory, an index.html, and several .js files.

  • If you open and run the index.html file of day-1, you can SEE what tests we have written for the day, and whether you are passing or failing those tests! You can run files by hitting the big "Run" button at the top of your workspace. Make sure you have the file you want to run selected!

  • Our work is going to be done in the .js files, like stringy.js and my-first-test.js. A .js file is a JavaScript file, which is the language we are mainly learning in this course. Inside these JavaScript files we will be creating code that fulfills certain tests we have already created.


Getting Started with Debugging

It is extremely important for you to begin debugging as you work. It's important to make use of console.log(someValue); to print expected values to the console and inspect your work. It is also highly valuable to get use to using breakpoints and the debugging tools of Cloud9 (and any other IDE you choose to use in the future)


Homework

Your homework assignments are located in JavaScript (.js) files in the directory homework of whichever day you are on.


Checking your Code

As you code your solutions and save your work, you have four options for checking your code:

  1. In the top level of the Scratch-Pad directory there is an index.html file. You can run this file to see ALL the tests we will be completing in this project!

  2. In each day-x directory there is an index.html file. Running this file will run all the unit tests only for that day.

  3. In your terminal you can test your code using the opspark client. To do so, run the command os test.

  4. To use the debugger and breakpoints and step thru your code, you can run your code by having the file selected in the text-editor and clicking the green Run button. This will open up a new process in the console view that will output your log statements. Breakpoints will be caught by the debugger and you can step through and inspect your code at runtime.

TIP It's important to note the difference between running .js files and .html files! JavaScript can do a bunch of awesome things, as you will see. Running a .js file means you are having each line of JavaScript code in the file run, one by one, from top to bottom. What it will NOT do is create a web page for you. In c9, running a .js file results in a new tab that shows everything that is console.logged in that file.

If you want to see an actual web page, you should run an .html file. Anything with the suffix .html is going to be HTML, or Hypertext Markup Language. HTML is like the skeleton of a website, it is the structure, so when you want to see a visualization of something you use HTML. It's possible for HTML to access your JavaScript files and run them inside the website, which we will play with more later in the course.