Programming Open textbook

JavaScript basics practice: script tags, variables, dates and arrays

Built automatically from early chapters of the open textbook "JavaScript" on Wikibooks: JavaScript in HTML, syntax, lexical structure, dates and arrays. Not reviewed by a person.

3 lessons, 13 steps

Get it on Google Play

JavaScript fundamentals, one question at a time

If you want to learn JavaScript from the ground up, or you already know another language and want to see where JavaScript behaves differently, this course replaces long reading with short questions on the fundamentals.

Lesson 1 covers how JavaScript gets into a web page: the script element, the src attribute for external files, what async and defer change about when a script runs, the noscript fallback, and a few contrasts with Java, such as const versus final. Lesson 2 is about syntax and scope: what a declared but unassigned variable holds, how automatic semicolon insertion can make a return statement give back undefined, how closures capture outside variables, and what happens when you skip the declaration keyword. Lesson 3 works with the Date object and arrays: what a Date stores internally, why getDay() counts from zero, and what push, shift and join return.

Each lesson starts with a brief explanation, then gives you four or five steps. Some are multiple choice, others ask you to type a keyword or a number, often after reading a short snippet of code. If your answer is wrong, the AI tutor asks a question aimed at the mistake, then gives a hint, then part of the solution. You can tap Show solution whenever you want it. A quick quiz before and after the lesson shows what moved.

The course was built automatically from the first chapters of the open textbook "JavaScript" on Wikibooks, and no person has reviewed it. The book is written by volunteers and may contain errors; these three lessons cover only its opening chapters.

What the lessons cover

  • Load scripts in HTML: script tags, deferred execution and noscript
  • Declare variables with let and const and predict undefined values, scope and closures
  • Spot what automatic semicolon insertion does to a return statement
  • Use Date and Array methods such as getDay, push, shift and join

Lessons

  1. JavaScript Basics and HTML Integration

    4 steps, 1 min intro

  2. Syntax and Lexical Structure

    4 steps, 1 min intro

  3. Working with Dates and Arrays

    5 steps, 1 min intro

A step from the arrays lesson

Tutor: Look at this code: const arr = [0, 1, 2, 3]; const len = arr.push(100); What number is stored in len?

You: 100

Tutor: Does push() return the element that was inserted, or does it return the count of elements?

You: The count. The array had 4 elements and now has 5, so len is 5.

Tutor: Right, 5. push adds 100 to the end and returns the new length of the array.

Based on a real step from lesson 3. The tutor's wording varies, and AI can be wrong: the tutor answers from the course material and labels a reply it could not check.

Who will get the most from it

  • You are starting to learn JavaScript and want to check your understanding with short questions.
  • You know Java or another C-family language and want to see where JavaScript differs.
  • You add small scripts to web pages and want to be clear on async, defer and script placement.
  • You prefer answering questions to rereading a tutorial.

JavaScript course FAQ

Do I write and run code in the app?

No. You read short code snippets and answer questions about them: pick an option, type a keyword such as shift, or enter the number a line of code returns. If you want to run the code too, your browser's developer console works alongside the course.

Who wrote the lessons?

They were generated automatically from the first chapters of the Wikibooks textbook "JavaScript", which volunteers write under the CC BY-SA 4.0 license. Nobody reviewed the course by hand, so if an answer looks wrong to you, check the original chapter listed in the sources on this page.

Is the course free?

One lesson in Ai Teacher is free. After that, a subscription opens all lessons. You can pay monthly or yearly in Google Play, and usage limits apply.

Source and license

This course is adapted from JavaScript, an open textbook on Wikibooks written by Wikibooks contributors (see the page history of each chapter below). The textbook is licensed under CC BY-SA 4.0.

This course was built automatically from the open textbook "JavaScript" on Wikibooks. No person has reviewed it. Changes: Adapted by AI into lessons and questions; shortened. Written by volunteers; it may contain errors.

Chapters used

  1. Introduction revision 4617930, authors
  2. Relation to other languages revision 4237043, authors
  3. First program revision 4237044, authors
  4. JavaScript within HTML revision 4632913, authors
  5. Syntax examples revision 4640773, authors
  6. Lexical structure revision 4393325, authors
  7. Automatic semicolon insertion revision 4519911, authors
  8. Dates revision 4237059, authors
  9. Arrays revision 4237058, authors

Start JavaScript in Ai Teacher

One lesson in the app is free. Ai Teacher is available for Android on Google Play.

Get it on Google Play