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

    Functions · Lesson 15 of 45

    Arrow functions

    A shorter way to write functions, and when not to.

    6 minutes4 games

    Important

    An arrow body with braces needs an explicit return to return a result.

    An arrow function is a shorter function: (params) => body. If the body is a single expression, its result is returned with no return or { }. With exactly one parameter the brackets are optional.

    JavaScript
    const square = n => n * n
    const add = (a, b) => a + b
    const greet = () => "Hello!"
    const describe = (name, age) => {
      const group = age >= 18 ? "adult" : "minor"
      return `${name} is an ${group}`
    }
    
    console.log(square(6), add(2, 3), greet())
    console.log(describe("Nour", 20))

    To return an object on one line, wrap it in brackets: () => ({ ok: true }). Without them, JavaScript reads { } as the function body.

    Interview question

    What's the key difference between arrow and regular functions?

    Quick question

    const add = (a, b) => a + b… what does add(2, 3) return?

    What's the output?

    const f = (x) => { x * 2 }
    console.log(f(5))

    What will this code print?

    Order the lines

    Order it to print true when the number is above 10.

    1. Click the lines in the right order

    Exercise

    Write an arrow function toCelsius converting Fahrenheit: (f - 32) * 5 / 9, then print toCelsius(212).

    Expected output: 100

    JavaScript

    Learn more from

    • javascript.info: Arrow functions, the basicsjavascript.info
    • MDN: Arrow function expressionsdeveloper.mozilla.org

    Played 0 of 4 games

    Sign in to save your progress and earn XP.

    PreviousFunctionsNextParameters: default, rest and spread
    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.