</>

Learn coding one step at a time

Learn programming in small, clear steps.

Short lessons, copy-and-run code examples, quick quizzes and step-by-step roadmaps. Free, beginner-friendly, and no account needed.

Per lesson
~5 minutes
Topics
8 tracks
Languages
English · ខ្មែរ
JavaScriptbeginner6 min read

JavaScript Functions

JavaScript
function addTax(price, rate) {
  const tax = price * rate;
  return price + tax;
}

const total = addTax(100, 0.1);
console.log(total);

Output → 110

How it works

Three steps per lesson

  1. 01

    Read a short lesson

    Each lesson explains one small concept in plain language, in about five minutes.

  2. 02

    Try the code

    Copy the example, run it yourself and compare it with the expected output.

  3. 03

    Check with a quiz

    Answer a few questions, get instant feedback, then move to the next step.

Lesson preview

Short lessons with real code

Every lesson has learning objectives, a code example with its expected output, and the mistakes beginners usually make.

JavaScriptbeginner6 min read

JavaScript Functions

A function is a reusable block of code. You give it inputs, it does some work, and it can give a value back with return.

Example · JavaScript
function addTax(price, rate) {
  const tax = price * rate;
  return price + tax;
}

const total = addTax(100, 0.1);
console.log(total);

Expected output

110

Common mistake: Forgetting return

Without return the function gives back undefined, so total would be undefined instead of 110.

Quiz preview

Check what you learned

Try it: answer the questions about the lesson above. You get instant feedback, a score, and a review of your mistakes.

Question 1 of 3Score: 0

What does `return` do inside a function?

Roadmaps

Know what to learn next

Roadmaps put lessons in order, so you always know your next step.

All roadmaps →

Web Developer roadmap

Beginner · About 4 months at 1 hour a day
  1. 1HTML
  2. 2CSS
  3. 3JavaScript
  4. 4Git & GitHub
  5. 5React
  6. 6Next.js
  7. 7Database basics
  8. 8Backend basics
  9. 9Build a project
  10. 10Deploy the website

AI tutor

An AI tutor beside every lesson

Stuck on a concept? Ask the AI tutor. It knows the lesson you're reading and can answer in English or Khmer. Free with a student account.

  • Ask about any lesson

    Get a simpler explanation and an extra example for the lesson you're reading.

  • Explain my code

    Press Explain in the playground for a step-by-step walkthrough of what each part does.

  • Fix my code

    Press Fix my code to send your code and its error, and get the likely cause and a fix.

  • English or Khmer

    Answers in either language, keeping code and keywords unchanged.

  • The tutor can't run code, so it always tells you when an answer is a likely cause rather than a confirmed one.

AI tutor

Lesson: JavaScript Functions

What does return mean in this function?

Explain this conceptShow another exampleExplain in KhmerHelp debug my codeGenerate five questions
Ask a question…Preview

What's here and what's next

Built step by step, like the lessons

Now

Learn and track your progress

  • Short lessons with code examples
  • Run JavaScript, HTML and SQL in your browser
  • Quizzes and step-by-step roadmaps
  • Free account, or sign in with Google: bookmarks, progress and quiz scores

New

AI learning assistant

  • Ask AI about any lesson
  • Code explainer and debugging help
  • Answers in English or Khmer

Later

More ways to learn

  • Saved AI chats
  • Personal learning plans
  • PHP and TypeScript in the playground

Ready to take your first step?

Pick a lesson. Most take about five minutes.

Start learning