Javascript Array convert via map()

Description

Javascript Array convert via map()



// function to convert decimal to hexadecimal
function convertToHex(element,index,array) {
   return element.toString(16);
}

let decArray = new Array(23, 255, 122, 5, 16, 99);

let hexArray = decArray.map(convertToHex);
console.log(hexArray); // 17,ff,a,5,10,63



PreviousNext

Related