Results for “Counter”
Small, practical examples. Search by task or narrow things down below.
Keep a mutable value without rendering on each write
Keep a mutable value without rendering on each write with a small React component and explicit browser behavior.
React✓ Tested
Keep component state with useState
Keep component state with useState with a small React component and explicit browser behavior.
React✓ Tested
Repeat an action a fixed number of times
Use a counter and delay for a simple finite sequence.
for loop✓ Tested
Use a counted Bash loop
Bash Scripts: Use a counted Bash loop with a small standalone Bash program.
Bash Scripts✓ Tested
Compare elapsed time across timer rollover
Use unsigned subtraction when a millisecond counter wraps.
rollover✓ Tested
Count a falling edge with an interrupt
Increment a counter when an external input changes.
attachInterrupt✓ Tested
Count words using a Map
Update a keyed counter without losing its value type.
Map✓ Tested
Iterate with array indices and values
JavaScript: entries provides each position and value without a separate counter.
JavaScript✓ Tested
Iterate with array indices and values
TypeScript: entries provides each position and value without a separate counter.
TypeScript✓ Tested
Keep loop state by avoiding a pipeline subshell
Bash Scripts: Redirect input into a while loop so updates to a counter remain in the current shell.
Bash Scripts✓ Tested
Number items while iterating
Python: Use enumerate to attach a one-based position without maintaining a separate counter.
Python✓ Tested
Pair corresponding array items by position
JavaScript: Validate equal lengths before zipping when missing counterparts would be an error.
JavaScript✓ Tested