Flowchart (ISO 5807)
Source code
TypeScript
function wordCount(s: string): number {
let count = 0;
let inWord = false;
for (let i = 0; i < s.length; i++) {
if (s[i] !== " ") {
if (!inWord) {
count++;
inWord = true;
}
} else {
inWord = false;
}
}
return count;
}The editor opens with this code — change it and the chart redraws.
- Language
- TypeScript
- Constructs
- loop over characters
- Topic
- Loops
- Formats
- Word, Visio, draw.io, PDF, SVG