+ 4

How to convert a number in binary to octal using javascript...?

Javascript

6th May 2020, 10:36 PM
Mustafha Ahmad
Mustafha Ahmad - avatar
7 ответов
+ 4
var binary = "10010100101"; var octal = parseInt(binary, 2).toString(8);
6th May 2020, 10:44 PM
P5YCH0x unknown
P5YCH0x unknown - avatar
+ 3
const octal = (binary) => { return parseInt(binary, 2).toString(8); } console.log(octal("1010")); // 12
6th May 2020, 10:51 PM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 3
Mustafha Ahmad Is this what you mean by full programme? :)) https://code.sololearn.com/WAAOPqq9L1cQ/?ref=app Just take an input and pass it to the function!
6th May 2020, 11:16 PM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 3
Vasiliy Nopes :)) Both of the examples are Alright. Binary : 1010 Decimal : 10 Octal : 12
6th May 2020, 11:58 PM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 3
Arb Rahim Badsa, thanks for the answer, I'm sorry, 2 a.m., brains twisted it's time to sleep 😕
7th May 2020, 12:30 AM
Solo
Solo - avatar
0
Can anyone please write full program
6th May 2020, 11:11 PM
Mustafha Ahmad
Mustafha Ahmad - avatar
0
Thank you
6th May 2020, 11:18 PM
Mustafha Ahmad
Mustafha Ahmad - avatar