diff options
Diffstat (limited to 'challenge-280/zapwai/javascript/ch-2.js')
| -rw-r--r-- | challenge-280/zapwai/javascript/ch-2.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/challenge-280/zapwai/javascript/ch-2.js b/challenge-280/zapwai/javascript/ch-2.js new file mode 100644 index 0000000000..e3a17ec1f1 --- /dev/null +++ b/challenge-280/zapwai/javascript/ch-2.js @@ -0,0 +1,21 @@ +let mystr = "p|*e*rl|w**e|*ekly|"; +proc(mystr); +mystr = "perl"; +proc(mystr); +mystr = "th|ewe|e**|k|l***ych|alleng|e"; +proc(mystr); +function proc(mystr) { + console.log("Input:", mystr); + let cnt = 0; + let words = mystr.split('|'); + for (let i = 0; i < words.length; i++) { + if (i % 2 == 0) { + for (let l of words[i].split("")) { + if (l == "*") { + cnt += 1; + } + } + } + } + console.log("Output:", cnt); +} |
