Choose unfinished objectives
v6 · Activity 5 of 5 · loops-and-conditions · filtering · 11 min Runs here
Chapter outline
A loop visits each objective; an if decides whether that objective belongs in the result. Filtering does not require changing the source sequence.
Start with an empty result and append only unfinished names. Returning the result after the loop handles a fully completed quest as an empty sequence.
Your task
remainingObjectives(objectives) returns names for complete=false entries in their original order. The starter selects the wrong state. Keep the final return shown in the starter so the checker can call or inspect your result.
Interface: remainingObjectives(objectives:{{name:string,complete:boolean}}) -> {string}
| Input | Expected |
|---|---|
Mixed quest{ { name = "Lamp", complete = true }, { name = "Gate", complete = false }, { name = "Bench", complete = false } } | { "Gate", "Bench" } |
All complete{ { name = "Lamp", complete = true } } | {} |
Syntax in this activity
New syntax: if inside a loop
Earlier ideas used here
- iteration
- dictionaries
- if-else
- table-insert
What this exercise checks
Actual returned results for every test input · the stated behavior · extra output allowed.
Successful execution is required. A compile error, runtime error or execution limit never completes this task.
Whitespace, matching single or double quotes, and different variable names are allowed. Output-only tasks accept any valid Luau solution meeting the displayed result and value types. Construct tasks use the stated straight-line form.
Explain this code
Select a word or symbol in this authored example. Your editor draft stays unchanged.
tasks name, complete, name, complete
remaining
_, task in tasks
task.complete table.insertremaining, task.name
remainingFree experiment
This is a private experiment copy. It does not replace your answer or complete the activity.
These inputs apply when your scratchpad returns the function described by the activity interface.
Your output will appear here.
remainingObjectives(objectives) returns names for complete=false entries in their original order. The starter selects the wrong state. Keep the final return shown in the starter so the checker can call or inspect your result.
Run code to see what happens. Check solution to test the activity.
Reset starter
Replace this code with the starter? Download your draft to keep a copy.
Code
LuauYour output will appear here.
Sign in with RoCreators to save private progress across devices. Community verification is separate.