The toolkit: slice(start,end) extracts; split(sep) makes an array; replace/replaceAll substitute; includes/startsWith/endsWith test; trim removes edge whitespace; padStart/padEnd pad. All return new strings (immutable).
The toolkit: slice(start,end) extracts; split(sep) makes an array; replace/replaceAll substitute; includes/startsWith/endsWith test; trim removes edge whitespace; padStart/padEnd pad. All return new strings (immutable).
<!doctype html><html><head><meta charset="utf-8"></head>
<body style="background:#06040d;color:#e6e0ff;font-family:monospace;padding:20px"><pre id="o"></pre>
<script>const s=' hello world ';
document.getElementById('o').textContent = s.trim().toUpperCase().replaceAll(' ','-');</script></body></html>▶ Open the interactive comic issue