Premium
Vue Dynamic Table (Rows × Columns)
Generate a dynamic table in Vue 3 from row/column inputs. Normalize inputs (clamp to 0/1), rebuild the grid on action, and render stable row/column labels so the UI stays predictable. Concepts: vue, components, reactivity. Vue focus: generate rows/cols with v-for and computed helpers. Framework focus:…
- Render the dynamic table UI as the main component.
- Provide two numeric inputs: one for the number of rows and one…
What you’ll build / What this tests
This premium vue coding focuses on Vue Dynamic Table (Rows × Columns). You’ll apply vue and components thinking with easy level constraints. The prompt emphasizes Generate a dynamic table in Vue 3 from row/column inputs. Normalize inputs (clamp to 0/1), rebuild….
Learning goals
- Translate the prompt into a clear vue API signature and return shape.
- Apply vue, components, reactivity techniques to implement vue dynamic table (rows × columns).
- Handle easy edge cases without sacrificing readability.
- Reason about time/space complexity and trade-offs in vue.
Key decisions to discuss
- Define the exact input/output contract before coding.
- Choose iteration vs higher-order methods for readability.
- Prioritize predictable edge-case handling over micro-optimizations.
Evaluation rubric
- Correctness: covers required behaviors and edge cases.
- Clarity: readable structure and predictable control flow.
- Complexity: avoids unnecessary work for large inputs.
- API discipline: no mutation of inputs; returns expected shape.
- Testability: solution is easy to unit test.
Constraints / Requirements
- Render the dynamic table UI as the main component.
- Provide two numeric inputs: one for the number of rows and one for the number of columns.
- Provide a button (e.g. "Generate table") that rebuilds the table when clicked.
- Render an HTML table whose number of rows and columns matches the current input values.
- Each cell should display something simple and visible, such as its row/column indices (e.g. R1C1).
- Initially, it is fine to show an empty state or no table. After clicking the generate button, a…
- Changing the row or column values and clicking the button updates the table dimensions.
- If the user enters non-positive values (0 or negative), the implementation may render no rows/columns or clamp the…
- Use Vue 3's Composition API inside .
- Use ref to store the numeric inputs and the rows/cols arrays that drive rendering.
Mini snippet (usage only)
// Example usage
const input = /* vue dynamic table (rows × columns) input */;
const result = solve(input);
console.log(result);
// Edge case check
const empty = input ?? null;
const fallback = solve(input);
console.log(fallback);
// Expected: describe output shape, not the implementation
// (no solution code in preview)Common pitfalls
- Mutating inputs instead of returning a new value.
- Skipping edge cases like empty input, duplicates, or nulls.
- Overlooking time complexity for large inputs.
Related questions
Upgrade to FrontendAtlas Premium to unlock this challenge. Already upgraded? Sign in to continue.