Skip to content

Latest commit

 

History

History
102 lines (70 loc) · 2.55 KB

File metadata and controls

102 lines (70 loc) · 2.55 KB

3. How to Write Code

[toc]


3.1. What is Code?

Code is a set of instructions for a computer to follow.

3.1.1. What Code Can Do

Here's a short list:

  1. Interact with users.
  2. Ineract with other systems.
  3. Repeat tedious tasks.
  4. Reuse useful code snippets.
  5. Make decisions. (Well, not the hard ones.)

3.2. Syntax Rules

Syntax referes to the structure of a language and the rules about that structure.

JavaScript, and other languages, can oly run if a program is syntactically correct, and each language is pretty rigid and unforgiving if you make a mistake.

3.3. Comments

A comment is text within a program intended to run for a human reader. It is completely ignored by the compiler or interpreter.

In Javascript, the // toke starts a comment, and the rest of the line gets gnored. For comments streched over multiple lines, the text falls between the symbols /* */.

// Single line comment
console.log("Hello, World!"); // The rest of this line is comments.

/* These comments crossing
 * multi-line of JavaScript
 * written as haiku!
 */

3.4. Output With console.log

3.4.1. Examples

3.4.2. Two FOUR Special Characters

🎗️ TODO: Create a list of escape characters later in the Computer Science folder.

Sequence Meaning Notes
\n New Line
\t (Horizontal) Tab Some editors process tabs equivalent to at least four spaces.
\' Single Quote Use this in single quoted strings.
\" Double Quote Use this in a double quote string.

3.5. Welcome, Novice Coder

Congradulations! You finished the prep work reading for LC101.

Some adive:

  1. Take advangage of the resources at your disposal--Your instructors, TAs, and classmates are here to help.
  2. Complete all the homework and practice taks. To learn how to code, you need to code.
  3. Ask and answer questions.
  4. Recognize that making mistakes is part of the learning process.

🏁 CHECKPOINT! Now you can do that Prep Work Quiz (or look over those last three chapters again.)

Ether way, let's move forward!

🏁 That was quick. Up next Data and Variables.


#LaunchCode