@anonymous/

PurpleIdolizedInstructions

Nodejs

No description

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function count(str) {
  var countForZero = 0;
  var countForOne = 0;
  for (var i = 0, length = str.length; i < length; i++) {
    if (str[i] === '0') {
      countForZero++;
    }
    else {
      countForOne++;
    }
  }
  return {
    'zero': countForZero,
    'One': countForOne
  };
}

count('100110011')
node v10.16.0