Results for “script”
Small, practical examples. Search by task or narrow things down below.
Stop a search loop at the first match
Bash Scripts: Break exits the current loop as soon as the desired item is found.
Bash Scripts✓ Tested
Store a value in a named variable
JavaScript: Give a value a descriptive name and print it.
JavaScript✓ Tested
Store a value in a named variable
TypeScript: Give a value a descriptive name and print it.
TypeScript✓ Tested
Store and iterate over an array
Bash Scripts: Store and iterate over an array with a small standalone Bash program.
Bash Scripts✓ Tested
Store text in a variable
Bash Scripts: Store text in a variable with a small standalone Bash program.
Bash Scripts✓ Tested
Substitute values into a multiline template
Bash Scripts: An unquoted heredoc delimiter enables parameter expansion in the template.
Bash Scripts✓ Tested
Sum numeric values
Provide an initial accumulator for JavaScript reduce, including empty arrays.
JavaScript✓ Tested
Test a function’s success status
Bash Scripts: Test a function’s success status with a small standalone Bash program.
Bash Scripts✓ Tested
Test numeric divisibility with a remainder
Bash Scripts: The modulo operator computes an integer remainder.
Bash Scripts✓ Tested
Transform a resolved promise result
JavaScript: A then handler returns the value passed to the next promise in the chain.
JavaScript✓ Tested
Transform a resolved promise result
TypeScript: A then handler returns the value passed to the next promise in the chain.
TypeScript✓ Tested
Transform array values
Use map to create a JavaScript array of squared values.
JavaScript✓ Tested