Sha256: 4092726ed527ce8efd540ca34096dfa79dd8341903bdc434890509d2532ecfd7

Contents?: true

Size: 301 Bytes

Versions: 396

Compression:

Stored size: 301 Bytes

Contents

'use strict';

module.exports = Binary;

function Binary(binary) {
  if (binary.match(/^[01]*$/)) {
    this.binary = parseInt(binary, 2);
  } else {
    this.binary = 0;
  }
}

Binary.prototype.toDecimal = function () {
  var out = Number(this.binary.toString(10));
  return isNaN(out) ? 0 : out;
};

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.179 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.178 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.177 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.176 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.175 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.174 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.173 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.172 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.171 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.170 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.169 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.167 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.166 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.165 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.164 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.163 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.162 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.161 tracks/javascript/exercises/binary/example.js
trackler-2.2.1.160 tracks/javascript/exercises/binary/example.js