Results for “while”
Small, practical examples. Search by task or narrow things down below.
Explain a calculation with a comment
TypeScript: Keep the code executable while documenting why a fixed input is used.
TypeScript✓ Tested
Explain a calculation with a comment
C++: Keep the code executable while documenting why a fixed input is used.
C++✓ Tested
Explain a calculation with a comment
C: Keep the code executable while documenting why a fixed input is used.
C✓ Tested
Fit an entire image inside a differently shaped box
CSS: Contain preserves the image aspect ratio while keeping all of it visible inside the specified content box.
CSS✓ Tested
Give a function an optional argument
Let callers omit a value while keeping nounset enabled.
optional argument✓ Tested
Handle a form locally
Prevent default form navigation while displaying input with jQuery.
jQuery✓ Tested
Hide interface controls in print layout
CSS: A print media query can retain article content while removing interactive controls.
CSS✓ Tested
Ignore small movements around a center value
Arduino / C: Values inside the deadband become zero while others keep their direction.
Arduino / C✓ Tested
Keep a decorative icon out of a button’s name
HTML: aria-hidden excludes a decorative character while leaving the visible action text as the accessible name.
HTML✓ 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
List newly added staged files only
Git: Filter the cached diff by added status while leaving modified files out.
Git✓ Tested
Loop over an array safely
Preserve spaces in array elements while iterating.
array✓ Tested