mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
updated file by JS standard
This commit is contained in:
@ -7,14 +7,11 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function binary_count_setbits(a) {
|
function BinaryCountSetBits (a) {
|
||||||
"use strict"
|
'use strict'
|
||||||
// convert number into binary representation
|
// convert number into binary representation and return number of set bits in binary representaion
|
||||||
let binA = a.toString(2)
|
return a.toString(2).split('1').length - 1
|
||||||
|
|
||||||
// return number of set bits in binary representaion
|
|
||||||
return binA.split("1").length - 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run `binary_and` Function to find the binary and operation
|
// Run `binary_and` Function to find the binary and operation
|
||||||
console.log(binary_count_setbits(251))
|
console.log(BinaryCountSetBits(251))
|
||||||
|
Reference in New Issue
Block a user