Results for “node”
Small, practical examples. Search by task or narrow things down below.
Split text on several separator characters
TypeScript: A regex character class can recognize alternative simple delimiters.
TypeScript✓ 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
Sum numeric values
Provide an initial accumulator for JavaScript reduce, including empty arrays.
JavaScript✓ Tested
Sum typed values with reduce
Accumulate numeric array elements.
reduce✓ 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
Transform each regex match with a callback
JavaScript: A replacement callback computes the replacement separately for each match.
JavaScript✓ Tested
Transform each regex match with a callback
TypeScript: A replacement callback computes the replacement separately for each match.
TypeScript✓ Tested
Trim and discard blank lines
JavaScript: Split a text block, trim each line, and keep nonempty values.
JavaScript✓ Tested
Trim and discard blank lines
TypeScript: Split a text block, trim each line, and keep nonempty values.
TypeScript✓ Tested