Back

Progress Bar I

easy

Streak

0 days

Progress

0%

Submitted

0

Progress Bar I

React25 mineasyFree

Prompt

Build this React exercise in 25 minutes.

Build a controlled ProgressBar({value, color, label}) with a live range-input demo. Clamp finite numeric values to 0–100; missing, nonnumeric, NaN, and infinite values resolve to 0. Preserve fractional percentages. Animate width with CSS, honor reduced-motion preferences, and give each bar a programmatic name. Indeterminate/loading bars are out of scope.

Acceptance checks

  • Values -5, 0, 45.5, 100, and 150 render 0%, 0%, 45.5%, 100%, and 100%.
  • NaN, Infinity, strings, and missing values render 0% without invalid ARIA values.
  • Slider changes update width, visible text, and aria-valuenow together; two bars have independent labels.
  • Reduced-motion disables the transition; the slider has a visible accessible label.

The checks are a manual interview checklist; saving a submission does not execute them.

Learn and continue

Prerequisite: Semantic HTML and accessibility. Work through the React Machine Coding Foundations path to practice related skills in order.

Requirements

  • →Values -5, 0, 45.5, 100, and 150 render 0%, 0%, 45.5%, 100%, and 100%.
  • →NaN, Infinity, strings, and missing values render 0% without invalid ARIA values.
  • →Slider changes update width, visible text, and aria-valuenow together; two bars have independent labels.
  • →Reduced-motion disables the transition; the slider has a visible accessible label.

Starter packet

What the interviewer handed you

Build a controlled ProgressBar({value, color, label}) with a live range-input demo. Clamp finite numeric values to 0–100; missing, nonnumeric, NaN, and infinite values resolve to 0. Preserve fractional percentages. Animate width with CSS, honor reduced-motion preferences, and give each bar a programmatic name. Indeterminate/loading bars are out of scope.

Manual acceptance checks

  • Values -5, 0, 45.5, 100, and 150 render 0%, 0%, 45.5%, 100%, and 100%.
  • NaN, Infinity, strings, and missing values render 0% without invalid ARIA values.
  • Slider changes update width, visible text, and aria-valuenow together; two bars have independent labels.
  • Reduced-motion disables the transition; the slider has a visible accessible label.

Likely follow-ups

  • • How would you represent unknown progress without a misleading percentage?
Example
Loading preview...
For the best coding experience, we recommend using a desktop device.
Preparing Sandbox...
Premium interview report

What interviewers score in this build

Use this before reading the code. It tells you what to say, what to test, and where machine-coding candidates usually lose points.

Interview signals

  • State and behavior: Values -5, 0, 45.5, 100, and 150 render 0%, 0%, 45.5%, 100%, and 100%.
  • Edge cases: Reduced-motion disables the transition; the slider has a visible accessible label.
  • Explanation: Explain the state model and demonstrate the acceptance checks.

Time checkpoints

  1. 1

    0:00: Read the contract and inspect the fixtures.

  2. 2

    8:00: Complete the state and interaction handlers.

  3. 3

    16:00: Check keyboard use and boundary behavior.

  4. 4

    25:00: Run every acceptance check and explain tradeoffs.

Edge-case checklist

Values -5, 0, 45.5, 100, and 150 render 0%, 0%, 45.5%, 100%, and 100%.
NaN, Infinity, strings, and missing values render 0% without invalid ARIA values.
Slider changes update width, visible text, and aria-valuenow together; two bars have independent labels.
Reduced-motion disables the transition; the slider has a visible accessible label.

Common mistakes

  • How would you represent unknown progress without a misleading percentage?
SolutionRead-only · Live Preview

Technical Explanation

Controlled means no mirrored state

The bar derives its width and ARIA value directly from props. Only the demo slider needs state. Mirroring value into another state creates synchronization problems.

Validate before clamping

Math.min/Math.max do not repair NaN. First accept only finite numbers, then clamp between zero and one hundred. Use the same result for width, text, and aria-valuenow.

Name the complete track

The track owns role=progressbar and references a unique visible label. The inner fill is decorative. CSS handles transitions, with a reduced-motion override; no interval is needed. Assistive-technology announcement frequency varies, so this is not a promise of automatic announcements on every change.

Interview Criteria

State and behavior

Values -5, 0, 45.5, 100, and 150 render 0%, 0%, 45.5%, 100%, and 100%.

Edge cases

Reduced-motion disables the transition; the slider has a visible accessible label.

Explanation

Explain the state model and demonstrate the acceptance checks.

Time Checkpoints

0:00

0:00: Read the contract and inspect the fixtures.

8:00

8:00: Complete the state and interaction handlers.

16:00

16:00: Check keyboard use and boundary behavior.

25:00

25:00: Run every acceptance check and explain tradeoffs.

Streak

0 days

Last active: Sign in to track

Progress

0%

0/0 solved

Submitted

0

Solutions pushed to review history.

More Machine Coding

View all Machine Coding →
Machine CodingMedium

React Tic-Tac-Toe Engine

Machine CodingMedium

Performant Image Slider

Machine CodingMedium

API Search and Render Image

Machine CodingEasy

Accessible React Tabs

Machine CodingMedium

Recursive File Explorer

Machine CodingEasy

Stopwatch

Related hubs

  • All machine coding
  • Frontend machine coding guide
  • React machine coding questions
  • UI coding interview questions
  • React UI interview questions
  • PayPal interview
  • Stripe interview
  • Uber interview