Search code examples
javascriptarraysoctal

Change Array with Integers into Octal Array


So if for example there was an array x = [34,10,60,5,3] how do I convert this to an array that's in octal?


Solution

  • You can do the following,

    x = [34,10,60,5,3]
    res = x.map(item => parseInt(item.toString(8)));
    console.log(res);