Fundamentals Lite
  • 🚀Course Overview
  • Course Logistics
    • 🏫Course Methodology
      • 🧩Course Components
      • 💬Course Communication
    • 💻Required Hardware and Software
      • ☝️Required Software 1
      • ✌️Required Software 2
      • 👍Recommended Setup
    • 📅Schedule
    • 💡Tips and Tricks
      • 📒Coding Strategies
      • 🛠️Tooling Pro Tips
    • 🎓Post-Course
      • 🚀Upgrading to Paid Fundamentals
      • 🚂Bootcamp Admission Criteria
      • 📹Bootcamp Video Application
  • 1: Introduction
    • 1.1: What is Coding?
    • 1.2: Web Browsers
    • 1.3: Command Line
    • Additional Resources 1
  • 2: Basic Data Manipulation
    • 2.1: Operations
    • 2.2: Variables
    • 2.3: Our First Program
    • Additional Resources 2
  • 3: Structuring and Debugging Code
    • 3.1: Functions
    • 3.2: Errors
    • Additional Resources 3
  • 4: Conditional Logic
    • 4.1: Intro to Logic
    • 4.2: Pseudo-Code, Boolean OR
    • 4.3: Boolean AND, NOT
    • 4.4: Input Validation
    • Additional Resources 4
  • 5: Managing State and Input Validation
    • 5.1: Program Lifecycle and State
    • 5.2: Program State for Game Modes
    • Additional Resources 5
  • 6: Arrays and Iteration
    • 6.1: Arrays
    • 6.2: Loops
    • 6.3: Loops with Arrays
    • Additional Resources 6
  • 7: Version Control
    • 7.1: Git
    • Additional Resources 7
  • 8: GitHub
    • 8.1: Intro to GitHub
    • 8.2: GitHub Fork and Clone
    • 8.3: GitHub Pull Request
    • 8.4: GitHub Repo Browsing
    • 8.5: Deployment
    • Additional Resources 8
  • Homeworks
    • Day 2: Basic File and Data Manipulation
    • Day 3: Functions
    • Day 4: If Statements, Boolean Or, Boolean And
    • Day 5: Program State
    • Day 7: Loops
    • Day 8: Arrays and Loops
  • Projects
    • Project 1: Scissors Paper Stone
      • Project 1: Scissors Paper Stone (Part 1)
      • Project 1: Scissors Paper Stone (Part 2)
    • Project 2: Beat That!
Powered by GitBook
On this page
  • Learning Objectives
  • Introduction
  • Setup
  • Exercises
  • Operators
  1. 2: Basic Data Manipulation

2.1: Operations

PreviousAdditional Resources 1Next2.2: Variables

Last updated 2 years ago

Learning Objectives

  • Use mathematical operators to perform mathematical operations in the console of the browser

Introduction

Coding means writing instructions for the computer to execute. We will begin with the most basic instructions the computer can execute, which is operations between 2 number values.

Setup

  1. Open a new tab in the Chrome browser by clicking File > New Tab, or pressing Cmd+T on Mac or Ctrl+T on Windows.

  2. Open Chrome Developer Tools by clicking View > Developer > JavaScript Console, pressing Cmd+Option+I on Mac or Ctrl+Shift+I on Windows, or right-clicking anywhere in Chrome and clicking Inspect.

  3. Select the Console tab in Chrome Dev Tools.

You can use Ctrl + L or Cmd + K to clear your console

Exercises

The JavaScript language is capable of performing math operations. Enter the following calculations into the Chrome Dev Tools Console, followed by the Enter key.

2 + 2;
4 * 2;
4 / 2;
4 - 2;

The input here is a mathematical equation typed in by the user, you. You have instructed the computer to perform a mathematical operation. The computer _returned _ an output, the evaluation of the equation.

These exercises may seem trivial, but mathematical operations are at the core of all computing instructions. Computers fundamentally compute. That being said, they can get things predictably wrong. Try: 0.1 + 0.2 in your console. Did you get what you expect?

Operators

In the above code, + * - and / are known as operators. Specifically, they are mathematical operators, as they perform a mathematical operation on 2 numbers. One other mathematical operator is the remainder operator, sometimes known as the modulus operator, defined with the % symbol. It returns the remainder after one number is divided by another; 10 % 3 will give us 1 because dividing 10 by 3 will result in a remainder of 1.

This course will only involve basic math: adding and subtracting (usually by 1), dividing and multiplying, and comparing numbers.

We will soon see other kinds of programming operators and operations; in the next section, we will see the assignment operator.

Coding Fundamentals will not cover why computers sometimes behave in odd ways, but you can read up more about this particular behaviour and .

here
here
Accessing the Developer tools in the Chrome browser setting
Chrome console allows for in-browser calculations