JSFiddle - React, Tailwind, and code Playground

by LyndseyB

HTML

Write a program which determines the number of 1 bits in the internal representation of a given integer.

JavaScript

var line = 10;

var str = line.toString(2), 
    strLen = str.length, 
    ones = str.replace(new                                                                                                                             RegExp('[0]','/g');


console.log(str);
console.log(ones);
console.log(ones.length);