Blog

Learn JavaScript

Start in your browser with nothing to install, learn the basics from MDN, then make web pages interactive and build three small projects you publish online.

In shortLearn JavaScript from scratch with an 8-week plan: basics from MDN, real code, interactive web pages, and three small projects you publish free.
Learn JavaScript

Learning JavaScript is the natural step after HTML and CSS, because it is the language that makes a web page interactive: a button that responds, a form that checks its data, a list that updates without a reload. The big advantage is that you can start right now in your browser with nothing to install. This guide gives you an eight-week plan, real code examples to try yourself, free official sources, and three small projects for your portfolio.

What is JavaScript and why learn it?

JavaScript is the programming language that runs inside every modern browser, and together with HTML and CSS it is the base of the web. HTML builds the content, CSS styles it and JavaScript makes it interactive. The Node.js runtime also lets it run outside the browser, so you can build servers and tools with it. One language opens both the front end and the back end.

You want toYou needAfter the basics
Build interactive websitesJavaScript with HTML and CSSA UI library such as React
Build servers and APIsJavaScript with Node.jsA server framework and databases
Build mobile appsJavaScript basics firstAn app framework that runs on JavaScript
Understand your graduation project codeThe basics and code readingThe browser developer tools
Comparison card of the guide table

Start now in your browser

  1. Open the developer tools

    In Chrome, Edge or Firefox on a computer, press F12 or right-click and choose Inspect, then open the Console tab.

  2. Write your first line

    Type console.log("Hello") and press Enter. The word appears right below. That is your first program.

  3. Try some maths

    Type 7 * 6 or 100 / 4. The console works as a calculator that speaks JavaScript.

  4. Move to a file

    Once you write more than two lines, create index.html and app.js in one folder, link them with a script line as in the example below, and open the page in your browser.

4-step flow: Open the developer tools / Write your first line / Try some maths / Move to a file

The basics in examples

These are the key ideas of the first two weeks. Type every example yourself in the console or in app.js instead of copying it, because typing is what fixes the syntax in your memory:

Variables and conditions
const name = "Sara";
let gpa = 4.2;

if (gpa >= 4.5) {
  console.log(name + " has an excellent GPA");
} else if (gpa >= 3.75) {
  console.log(name + " has a very good GPA");
} else {
  console.log(name + " can raise her GPA");
}

Use const for values that do not change and let for values that will. Avoid var in new code. Note that == and === are different: the second compares both value and type, so use it every time.

Functions, arrays and loops
function average(marks) {
  let total = 0;
  for (const mark of marks) {
    total += mark;
  }
  return total / marks.length;
}

const quizzes = [80, 92, 75, 88];
console.log(average(quizzes));

const passed = quizzes.filter(m => m >= 80);
console.log(passed);

The average function takes an array of marks and returns the mean. filter is one of the most important array methods, along with map and reduce. Learn them early because you will see them in all modern code.

Make the page interactive

This is where the fun starts. The browser represents the page as a tree of elements called the DOM, and JavaScript can read any element, change it and respond to clicks. Here is a complete study counter in two files:

index.html
<!DOCTYPE html>
<html lang="en">
<body>
  <h1>Study sessions: <span id="count">0</span></h1>
  <button id="add">Add a session</button>
  <script src="app.js"></script>
</body>
</html>
app.js
const countEl = document.querySelector("#count");
const button = document.querySelector("#add");
let count = 0;

button.addEventListener("click", () => {
  count++;
  countEl.textContent = count;
});

Open index.html in your browser and press the button. querySelector finds the element, addEventListener waits for the click and textContent changes the text. These three alone build dozens of small projects.

An eight-week plan

  1. Weeks 1 and 2: the basics

    Variables, types, conditions, loops and functions, from the MDN JavaScript Guide. One hour a day, with five small exercises per session.

  2. Week 3: arrays and objects

    Arrays and their methods map, filter and reduce, and objects to represent data such as a student with a name, a GPA and courses.

  3. Week 4: the DOM and events

    Selecting and changing elements and responding to clicks and typing. Build project one: a to-do list that adds and removes items.

  4. Week 5: data and storage

    Saving data in the browser with localStorage and converting it with JSON. Upgrade the to-do list so it survives closing the page.

  5. Week 6: fetching data

    Use fetch with async and await to load data from a public API and display it. Project two: a page that shows live data from the internet.

  6. Week 7: Git and publishing

    Learn Git, push your projects to GitHub and publish them free with GitHub Pages. Activate the GitHub Student Developer Pack with your university email.

  7. Week 8: a project of your choice

    Project three solves a problem you have: a GPA calculator, a study timer or a short quiz for a course. Write a README that explains it.

Free official sources

  • MDN Learn web development: a full curriculum from Mozilla that starts with HTML and CSS, then JavaScript, with exercises and assessments.
  • MDN JavaScript Guide: the reference you will return to for every language question.
  • Node.js Learn: for when you finish browser basics and want to run JavaScript on your computer or build a server.
  • A good code editor. JetBrains tools are free for students, listed in free software for students.

Use AI as a tutor, not a writer

If you ask an AI assistant to write all the code, you learn nothing. Ask it to explain, question and review instead. Try these with ChatGPT or Claude:

JavaScript tutor
You are my JavaScript tutor. I am a beginner and today I am learning [arrays / functions / the DOM]. Explain the idea in 5 short lines with one tiny example. Then give me 3 exercises, one at a time, from easy to harder. Do not show the solution until I send my code. When I send it, point out mistakes and ask me a question that leads me to the fix instead of rewriting it.
Explain my error
My JavaScript code gives this error: [paste error]. Here is the code: [paste code]. Explain in simple words what the error means and which line causes it. Give me a hint first, not the full fix.
  • GitHub: GitHub offers GitHub Student Developer Pack to university students in Saudi Arabia for free.
  • JetBrains: JetBrains offers JetBrains Student Pack to university students in Saudi Arabia for free.
  • Google AI: Google AI offers Google AI Plus free for a year to university students in Saudi Arabia.

Beginner mistakes

  • Jumping to a framework like React before the basics, so everything feels like magic you cannot follow.
  • Watching lessons without writing code. Every hour of watching needs at least an hour of typing.
  • Ignoring error messages in the console. Always read them, because they name the file and line.
  • Using == instead of ===, and var instead of let and const.
  • Not publishing projects. A live project with a link helps you in co-op training and interviews far more than one on your laptop.

If you have not picked a direction in programming yet, start with how to learn programming from zero. Once you have projects, gather them on one page with how to build a portfolio, and if your projects need to store data, learn SQL.

Questions

Where do I start learning JavaScript?

Start in the browser console with nothing to install, then follow MDN Learn web development, which covers HTML and CSS before JavaScript, and build a small project every two weeks.

How long does it take to learn JavaScript basics?

At an hour a day, about eight weeks covers the basics, working with the page, fetching data and three small projects. Getting really good takes more projects after that.

Should I learn HTML and CSS before JavaScript?

Yes, for at least two weeks. JavaScript on the web works with page elements, and knowing how a page is built makes everything easier.

What is the difference between Java and JavaScript?

They are completely different languages despite the similar name. JavaScript is the language of the web, in the browser and in Node.js. Java is a separate language used for other kinds of apps and systems.

Should I use AI to write my code?

Use it to explain ideas and errors and to review your code, and write the code yourself. That is what makes you actually learn.

Sources

  1. developer.mozilla.org: developer.mozilla.org/en-US/docs/Learn_web_development
  2. developer.mozilla.org: developer.mozilla.org/en-US/docs/Web/JavaScript/Guide
  3. developer.mozilla.org: developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model
  4. nodejs.org: nodejs.org/en/learn
  5. docs.github.com: docs.github.com/en/pages/quickstart

Hear when tiswa opens.

Join the free waitlist. We notify you at launch; then verify as a student and access the deals under their terms.

  • Free for good
  • No card
  • Takes a minute
Join the waitlist

More articles