Find a course
Age level: Adults & professionals (18+)BeginnerTechnology & Programming

JavaScript for Beginners

Variables, functions, arrays, objects, the DOM and async code

⏱ 2 h 10 min5 modules · 12 lessons75 practice questionsFinal exam: 20 questions
Included with this course

Your certificate for this course

Finish the 12 lessons (about 2 h 10 min) and pass the 20-question final exam. Your Certificate of Completion is ready the moment you pass.

  • Your name and this course titlePrinted in classic diploma typography
  • Grade: Pass, Merit or DistinctionOn the gold seal, with your final score
  • Unique ID and QR codeAnyone can verify it in seconds
  • Score report PDFModule-by-module results and exam score
  1. Lessons12 lessons
  2. Final exam20 questions · 70% to pass
  3. CertificatePDF + score report

What you will learn

  • Write and run JavaScript in the browser, and read console output and error messages
  • Declare variables with let and const and work with numbers, strings, booleans, null and undefined
  • Predict type coercion, compare values safely with ===, and control program flow with if, else and logical operators
  • Write functions with parameters, return values and arrow syntax, and understand block scope
  • Use for, while and for...of loops with the accumulator pattern, avoiding off-by-one errors
  • Store and transform data with arrays, map, filter, reduce and sort, and model real things with objects
  • Select and change page elements through the DOM and respond to user events safely
  • Debug systematically, handle errors with try...catch, and load data asynchronously with promises, async/await and fetch

About this course

JavaScript is the language of the web. It runs in every browser, powers interactive pages and web apps, and with Node.js runs servers and tools too. If you want to build websites, move into software development, automate tasks, or simply understand how the apps you use every day work, JavaScript is one of the most practical first languages you can learn.

This free course teaches the core language from zero. You will start with what JavaScript is, where it runs and how to write and run your first statements. Then you will learn to store data in variables, work with numbers, strings and booleans, and avoid the type coercion surprises that make "1" + "1" equal "11". You will make programs decide with if, else and logical operators, package logic into functions, and repeat work with loops.

The middle of the course covers the data structures real programs are built on: arrays, the map, filter and reduce methods that transform them, and objects for modeling users, products and orders. The final module connects it all to the browser: selecting and changing page elements through the DOM, responding to clicks and form input, reading error messages and debugging systematically, and loading data from web APIs with promises, async/await and fetch.

Every lesson mixes short explanations and worked examples with hands-on practice, including code challenges that run your JavaScript in the browser and check it against tests. No installation is needed. The course is for complete beginners and for people who have copied snippets before but want to really understand them. Pass the final exam to earn a free certificate of completion.

Syllabus

  1. Getting Started

    See what JavaScript is and where it runs, write your first statements, and store data in variables of different types.

    1. What JavaScript Is and Your First Lines10 min
    2. Variables and Data Types12 min
  2. Operators and Decisions

    Calculate with operators, avoid type coercion surprises, compare with ===, and make programs choose with if, else and logical operators.

    1. Operators, Expressions and Type Coercion12 min
    2. Making Decisions with if, else and Logic13 min
  3. Functions and Loops

    Package logic into reusable functions with parameters and return values, then repeat work efficiently with loops.

    1. Functions: Reusable Blocks of Code13 min
    2. Loops: Repeating Work13 min
  4. Arrays and Objects

    Store lists in arrays, transform them with map, filter and reduce, and model real-world data with objects.

    1. Arrays: Lists of Values12 min
    2. Transforming Data with map, filter and reduce14 min
    3. Objects: Grouping Related Data13 min
  5. Web Pages, Errors and Async Code

    Use JavaScript to change web pages and respond to users, debug and handle errors, and load data asynchronously with promises and fetch.

    1. Controlling a Web Page: the DOM and Events13 min
    2. Errors, Debugging and try...catch12 min
    3. Asynchronous JavaScript: Timers, Promises and fetch14 min
  6. Final exam and certificate

    20 questions drawn from a pool of 33. Score 70% or more to pass; retakes get a fresh set of questions.

Try a sample question

What does this program print? ``js console.log("2 + 3"); console.log(2 + 3); ``

  1. 5, then 5
  2. 2 + 3, then 2 + 3
  3. 2 + 3, then 5
  4. An error
Show the answer

Answer: C. 2 + 3, then 5

The first line logs a string, so the characters "2 + 3" are printed exactly as written. The second line has no quotes, so JavaScript evaluates the expression and prints 5. Quotes are the difference between text and code.

Variable
A named container that stores a value so a program can use it later.
let
Keyword that declares a block-scoped variable that can be reassigned.
const
Keyword that declares a block-scoped variable that cannot be reassigned.
String
A sequence of characters (text) written in quotes or backticks.
Boolean
A value that is either true or false.
undefined
The value of a variable or property that has not been given a value.

Frequently asked questions

Is JavaScript a good first programming language?

Yes, for most people. It runs in any browser with no installation, you see results immediately on real web pages, and it is used for front ends, back ends and tools. Its quirks, such as type coercion, are worth learning carefully, and this course points them out as you go.

What is the difference between JavaScript and Java?

They are unrelated languages with different designs and uses. The similar name came from a 1990s marketing decision. JavaScript runs in browsers and on servers through Node.js; Java is a separate language commonly used for enterprise software and Android apps.

Should I use let, const or var?

Use const by default and let when a variable must be reassigned. Avoid var in new code: it has function scope and other behaviors that cause confusing bugs. You will still see var in older code and tutorials.

Do I need to learn HTML and CSS before JavaScript?

Not to learn the language itself, which is what most of this course covers. To build web pages you will want basic HTML and CSS as well, because JavaScript controls page elements that HTML defines and CSS styles.

How long does it take to learn JavaScript?

You can learn the fundamentals in this course in a couple of hours of focused study. Becoming comfortable building small projects usually takes a few weeks of regular practice, and professional-level skill takes months of building real things.

What should I learn after the basics?

Build small projects: a to-do list, a quiz, a weather page using a public API. Then learn more about the DOM, modules, Git, and either a front-end framework or Node.js for servers, depending on your goals.

Why does 0.1 + 0.2 not equal 0.3 in JavaScript?

Numbers are stored in binary floating point, which cannot represent some decimals exactly, so 0.1 + 0.2 gives 0.30000000000000004. Most languages behave the same way. Round for display with toFixed, or work in whole units such as cents for money.

Sources and further reading

Related courses

TeensBeginner

Make Games with JavaScript

Code real browser games with variables, loops, canvas drawing, keys and collisions

Technology & Programming
2 h11 lessonsCertificate
Adults & professionalsBeginner

Python for Beginners

Write real programs with variables, loops, lists, dictionaries and functions

Technology & Programming
2 h 15 min12 lessonsCertificate
TeensBeginner

Python for Teens

Write real programs: games, quizzes and calculators from your first line of code

Technology & Programming
1 h 55 min10 lessonsCertificate
KidsBeginner

Coding for Kids

Algorithms, loops, if-then, variables and bug hunting, then write real JavaScript

Technology & Programming
1 h7 lessonsCertificate
Adults & professionalsBeginner

Git and GitHub Basics

Track changes, branch safely and collaborate with pull requests

Technology & Programming
2 h12 lessonsCertificate
University studentsIntermediate

Regular Expressions

Match, extract and replace text with regex in JavaScript, Python and your editor

Technology & Programming
2 h 45 min12 lessonsCertificate