JavaScript Program to Converter a Decimal to Octal

You are Here:

Converter a Number from Decimal to Octal

In the following example, we will convert a Decimal Number (100) to Octal Number (144).

Tips: It is recommended to use our online Decimal to Octal calculator for better understanding.

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <h1>JS Decimal to Octal Converter</h1> <script> var num = 100; var arr = []; var i; var answer = []; var value = 1; var j = 0; var count = -1;while(num > value) { count++; value = Math.pow(8, count); console.log(value); arr[count] = value; } count = count - 1; console.log("next"); for(i=count; i>=0; i--) { answer[j] = Math.floor(num / arr[i]); j++; console.log(num); num = num % arr[i]; } for(i = 0; i<=count; i++) document.write(answer[i]); </script> </body> </html>

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author