Open this example in the interactive library
Live preview
Source code
// components/LongestWordInspector.tsx
export default function LongestWordInspector({
source = "Copper Studio North",
}: { source?: string } = {}) {
const words = source.trim().split(/\s+/);
const longest = words.reduce((a, b) => (b.length > a.length ? b : a), "");
return (
<output>
Longest word: {longest} ({longest.length})
</output>
);
}
