Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    JSJavaScript

    Getting started

    • What is JavaScript?
    • Variables: let, const and var
    • Data types
    • Type conversion

    Operators and strings

    • Arithmetic and assignment
    • Comparison and logic
    • Strings and template literals
    • String methods
    • Numbers and Math

    Control flow

    • Conditions: if and else
    • switch and the ternary operator
    • Loops: for and while
    • Challenge: FizzBuzz

    Functions

    • Functions
    • Arrow functions
    • Parameters: default, rest and spread
    • Scope and closures
    • Callbacks and higher-order functions

    Arrays

    • Array basics
    • map, filter and find
    • reduce and sorting
    • Destructuring

    Objects

    • Object basics
    • Copies and references
    • Methods and this
    • JSON and optional chaining

    Classes and OOP

    • Classes
    • Inheritance

    JavaScript in the page

    • Controlling the page (DOM)
    • Creating elements
    • Events
    • Forms and validation
    • Saving in the browser (localStorage)

    Errors and async

    • Handling errors: try and catch
    • Timers and the event loop
    • Promises
    • async and await
    • Fetching data from an API

    Practical tools and techniques

    • Searching with regular expressions
    • Cancellation and stale results
    • Testing and debugging JavaScript

    Modern JavaScript and a project

    • Map and Set
    • Dates and localised formatting
    • Modules: import and export
    • Project: a complete to-do app
    JavaScript

    Operators and strings · Lesson 5 of 45

    Arithmetic and assignment

    Add, subtract, remainder and powers, plus += and ++.

    7 minutes3 games

    The basic operators are +, -, * and /. Two more are important:

    • % remainder: 17 % 5 is 2. Very handy: n % 2 === 0 means n is even.
    • ** power: 2 ** 10 is 1024.

    Precedence follows maths: multiply and divide before add and subtract, brackets before everything.

    JavaScript
    console.log(17 % 5)        // 2
    console.log(2 ** 10)       // 1024
    console.log(2 + 3 * 4)     // 14
    console.log((2 + 3) * 4)   // 20
    console.log(7 / 2)         // 3.5
    console.log(Math.floor(7 / 2)) // 3

    Assignment shortcuts

    Step by step1 / 5
    1. ▶let likes = 9
    2. 2likes += 1
    3. 3likes *= 2
    4. 4likes++
    5. 5console.log(likes)

    Variables

    likes9

    Output

    …

    Important

    0.1 + 0.2 isn't exactly 0.3; it's 0.30000000000000004, because computers store fractions in binary. For money, work in cents (whole numbers) or round with toFixed(2).

    Interview question

    What's the difference between i++ and ++i?

    What's the output?

    console.log(10 % 3)
    console.log(2 + 2 * 2)

    What will this code print?

    Complete the code

    Add price to total using the shortcut.

    let total = 100
    const price = 25
    total  price

    Exercise

    Print how many minutes are in 3 hours and 20 minutes (200).

    Expected output: 200

    JavaScript
    const hours = 3
    const minutes = 20
    

    Learn more from

    • javascript.info: Basic operators, mathsjavascript.info
    • MDN: Expressions and operatorsdeveloper.mozilla.org
    • MDN: Remainder (%)developer.mozilla.org

    Played 0 of 3 games

    Sign in to save your progress and earn XP.

    PreviousType conversionNextComparison and logic
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.