mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 00:01:37 +08:00
updated file by JS standard
This commit is contained in:
@ -7,14 +7,11 @@
|
||||
|
||||
*/
|
||||
|
||||
function binary_count_setbits(a) {
|
||||
"use strict"
|
||||
// convert number into binary representation
|
||||
let binA = a.toString(2)
|
||||
|
||||
// return number of set bits in binary representaion
|
||||
return binA.split("1").length - 1
|
||||
function BinaryCountSetBits (a) {
|
||||
'use strict'
|
||||
// convert number into binary representation and return number of set bits in binary representaion
|
||||
return a.toString(2).split('1').length - 1
|
||||
}
|
||||
|
||||
// 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