Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function streamOfLetters(input) {
- let word = '';
- let total = '';
- let c = 0;
- let o = 0;
- let n = 0;
- let counter = 0;
- while (true) {
- let letter = input[counter++];
- if (letter === 'End') {
- break;
- }
- if (letter >= 'A' && letter <= 'Z' || letter >= 'a' && letter <= 'z') {
- if (letter === 'c' && c === 0) {
- c += 1;
- } else if (letter === 'o' && o === 0) {
- o += 1;
- } else if (letter === 'n' && n === 0) {
- n += 1;
- } else {
- word += letter;
- }
- if (c === 1 && o === 1 && n === 1) {
- c -= 1;
- o -= 1;
- n -= 1;
- total += ' ' + word;
- word = '';
- }
- }
- }
- console.log(total);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement