aboutsummaryrefslogtreecommitdiff
path: root/challenge-279/zapwai/javascript/ch-2.js
blob: dab758c64ec406718235b5392d51bcbdbb52495e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
let str = "perl";
proc(str);
str = "book";
proc(str);
str = "goodmorning";
proc(str);

function is_vowel(c) {
    if (c == 'a' ||
	c == 'e' ||
	c == 'i' ||
	c == 'o' ||
	c == 'u') {
	return true;
    }
    return false;
}

function proc(str) {
    console.log("Input: str = ", str);
    let cnt = 0;
    for (let c of str) {
	if (is_vowel(c)) {
	    cnt++;
	}
    }
    if (cnt % 2 == 0) {
	console.log("Output: true");
    } else {
	console.log("Output: false");
    }
}