I just want the background color to be changed when the bottom is clicked using javascript.And also want to display the hex Value of the corresponding color.It should be a random selection from the code.
I actually created array of hexadecimal characters and created a function to generate the hexadecimal values.But i am unable to display the code to the screen.
var color=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];
function getRandNumber(min,max){
 return Math.floor(Math.random()*(max-min+1))+min;
}
var button = document.querySelector(".color");
button.addEventListener("click",()=>{
 document.body.style.backgroundColor = "#" 
                                     + color[getRandNumber(0,15)]
                                     + color[getRandNumber(0,15)]
                                     + color[getRandNumber(0,15)]
                                     + color[getRandNumber(0,15)]
                                     + color[getRandNumber(0,15)]
                                     + color[getRandNumber(0,15)]
                                     
 console.log(document.body.style.backgroundColor);
 document.querySelector(".colorName").innerHTML = document.body.style.backgroundColor
})
The result of console logging is in the rgb() form.Is there any way to get it in hex form.I just want to output the hex value of the background color.
 
     
    