Use these notes to review a concept or read at your own pace. The interactive workspace above adds predictions, editable code, and actual run results.
IDEA 1
Values and names
A value is one piece of information. In JavaScript, 20 is a number, 'Read chapter' is a string of text, and true is a boolean used for yes/no conditions. Quotation marks matter: '20' is text rather than a number.
Use const to give a value a name when you do not need to reassign that name. A meaningful name such as minutesPerPart helps someone inspect the calculation. These first functions are deterministic: the same input gives the same output without a model.
Name the quantities
- Count. There are three parts to the task.
- Estimate. Each part is estimated at eight minutes.
- Compute. Multiply numbers to obtain a total of 24 minutes.
Authored task estimate; these numbers are assumptions for practice.
Text and numbers behave differently
const a = 8 + 2; // 10
const b = "8" + 2; // "82"With a string, + can join text. Our case inputs use numeric durations so arithmetic has the intended meaning. A later lesson will validate types.
Think it through: Which value is a number?
IDEA 2
Objects hold related facts
An object groups related values under property names. A fictional task can have label, parts, minutesPerPart, and breakMinutes fields. Dot notation reads a property: task.label gets its text label.
Property names connect the data to the code. If the input uses parts, reading input.chapters will not magically find it. Keep the contract small and inspect the actual field names before calculating.
Read a task card
- Card. Related values arrive together as one input object.
- Property. Read the count by its exact name.
- Use. Read another field for the multiplication.
One object groups an estimate without needing a spreadsheet or database.
Keep a label attached to its number
const task = { label: "Sketch", parts: 2 };
const label = task.label;
const count = task.parts;task is the object. label and parts are property names, and the dot selects the corresponding value. count now holds 2.
Think it through: What does input.parts read?
IDEA 3
A function turns an input into an output
A function names a reusable piece of code. Its parameter, input, is a local name for the value supplied by the caller. A return statement sends a result back and ends that function call.
Our solve function calculates study minutes, adds a break only when there is work, and returns an object. It does not know whether the estimate is realistic. Changing the fictional input lets you test the calculation separately from the assumptions.
One function, different cards
- Input. Two parts, ten minutes each, and a five-minute break.
- Function. Calculate 20 work minutes, then add the break.
- Output. The caller can read a consistent named result.
The calculation runs as JavaScript; no model chooses the answer.
A return ends the calculation
function double(value) {
return value * 2;
}
const result = double(6); // 12Calling double passes 6 into the parameter value. The expression evaluates to 12, and return supplies that value to result.
Think it through: What changes when double(6) becomes double(4)?
Put it into practice
Return the task label, work minutes, and total minutes, with no break added for an empty task.
- Read the four properties in the case input.
- Run the starter and notice that workMinutes stays at zero.
- Replace the work calculation with the multiplication snippet.
- Test a changed estimate and the zero-parts case.
Your next experiment: Double minutesPerPart. Predict which output fields change before running.
Name values, read the actual input, and return a result you can predict.
Key terms
- Parameter
- A name used inside a function for a value passed by its caller.
- Property
- A named field of an object.
- Return
- Send a value back from a function and end that call.
Sources and scope
Original Stemtiq teaching, reviewed 2026-09-14. The named researchers and organizations do not endorse this course. Classroom cases are authored exercises, not published findings.
MDN Web Docs: JavaScript Guide
Updated 7 November 2025
Functions, objects, conditions, loops, and asynchronous code provide the programming foundations for an agent controller.
Ordinary JavaScript rules do not imply that a language model is running. An execution environment may support only part of the language or its host APIs.