Ready. Start with one instruction.
Loading the learning workspace…
FROM YOUR FIRST INSTRUCTION TO A WORKING APPLICATION
Learn JavaScript from scratch through small working examples, visual experiments and complete projects. No account or AI key required.
Predict → Experiment → Build → Test → Explain
Ready. Start with one instruction.
Loading the learning workspace…
fetch normally performs a request and returns a promise for a Response. To make this exercise reproducible without network access, fixtureFetch is an explicitly supplied local adapter with the same small response-reading interface. It is not a real server request. The code awaits the response, then awaits its JSON body. In production, use a permitted URL and check response.ok before reading usable data.
async function solve(path) {
const response = await fixtureFetch(path);
if (!response.ok) return "Unavailable";
const data = await response.json();
return data.title;
}
console.log(await solve("/course"));JavaScript Discovery
The local adapter returns a success or missing-response fixture based on the path.
async function solve(path) {Define a reusable function. Names inside its parentheses are parameters; actual arguments arrive when it is called. Defining the function does not run it.
const response = await fixtureFetch(path);Declare response with const. The binding cannot be reassigned. The expression after = supplies its initial value; = is assignment, not an equality comparison.
if (!response.ok) return "Unavailable";Choose a branch according to this condition. Only the selected path runs for this input; inspect the exact comparison and its boundary.
const data = await response.json();Declare data with const. The binding cannot be reassigned. The expression after = supplies its initial value; = is assignment, not an equality comparison.
return data.title;Evaluate the expression after return, end this function call, and give that value to the caller. The result is not automatically displayed.
}Close the current instruction block.
console.log(await solve("/course"));Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
async function solve(path) {
const response = await fixtureFetch(path);
if (!response.ok) return "Unavailable";
const data = await response.json();
return data.title;
}
console.log(await solve("/missing"));Unavailable
The local adapter returns a success or missing-response fixture based on the path.
async function solve(path) {Define a reusable function. Names inside its parentheses are parameters; actual arguments arrive when it is called. Defining the function does not run it.
const response = await fixtureFetch(path);Declare response with const. The binding cannot be reassigned. The expression after = supplies its initial value; = is assignment, not an equality comparison.
if (!response.ok) return "Unavailable";Choose a branch according to this condition. Only the selected path runs for this input; inspect the exact comparison and its boundary.
const data = await response.json();Declare data with const. The binding cannot be reassigned. The expression after = supplies its initial value; = is assignment, not an equality comparison.
return data.title;Evaluate the expression after return, end this function call, and give that value to the caller. The result is not automatically displayed.
}Close the current instruction block.
console.log(await solve("/missing"));Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
async function solve(path) {
const response = await fixtureFetch(path);
if (!response.ok) return "Unavailable";
const data = await response.json();
return data.title;
}
console.log(await solve(""));Unavailable
The local adapter returns a success or missing-response fixture based on the path.
async function solve(path) {Define a reusable function. Names inside its parentheses are parameters; actual arguments arrive when it is called. Defining the function does not run it.
const response = await fixtureFetch(path);Declare response with const. The binding cannot be reassigned. The expression after = supplies its initial value; = is assignment, not an equality comparison.
if (!response.ok) return "Unavailable";Choose a branch according to this condition. Only the selected path runs for this input; inspect the exact comparison and its boundary.
const data = await response.json();Declare data with const. The binding cannot be reassigned. The expression after = supplies its initial value; = is assignment, not an equality comparison.
return data.title;Evaluate the expression after return, end this function call, and give that value to the caller. The result is not automatically displayed.
}Close the current instruction block.
console.log(await solve(""));Evaluate the argument and display its value at this point. Quoted text is literal; an unquoted identifier reads its current binding.
Repair the intentionally changed operation so the example produces the exact expected result. Then try the extension without copying the answer.
async function solve(path) {
const response = await fixtureFetch(path);
if (response.ok) return "Unavailable";
const data = await response.json();
return data.title;
}
console.log(await solve("/course"));async function solve(path) {
const response = await fixtureFetch(path);
if (!response.ok) return "Unavailable";
const data = await response.json();
return data.title;
}
console.log(await solve("/course"));A fulfilled fetch promise can still represent an unsuccessful HTTP status.
Which operation changed the result, why did it work, and what would you test next?
Use a different value that could expose a boundary or mistake. Predict the result first, run it, and explain how the concept would help in a small real application.
Related: Previous lesson Next lesson
100 lessons across 20 modules, covering variables, operators, strings, conditions, loops, functions, scope, arrays, objects, DOM, events, state, testing, asynchronous JavaScript and application development.