JavaScript Challlenge: Hex Background Color Change. Trouble with my code?

Hi everyone!

I decided to start the 100+ JavaScript projects from JS Beginners and I’m on the second challenge. I am rather ashamed to say how long I’ve been working on it. This is the solution code that I worked on:

const body = documet.querySelector('body');
const hexArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F'];
const hexValue = document.querySelector('#hex-value');
const button = document.querySelector('button')

function hex() {
    let hexColor = '#'
    for(var i = 0; i < hexArray.length; i++) {
    hexValue = hexColor + hexArray*Math.floor(Math.random().toString(16));
    button.addEventListener('click', hex);

I’ve been trying for nearly a week to get this running correctly, but to no avail. I would appreciate any guidance towards the solution as to why my code is not working. I’m missing something, perhaps what’s written makes no sense and is all wrong? As someone new to JavaScript, any help/advice/guidance is greatly appreciated.

I would also appreciate it if anyone would mind sharing any advice on how to better myself at writing JavaScript? As someone who aspires to work as a professional front-end developer, I don’t want to get stuck in ‘tutorial ■■■■’, I can read and understand the code that is written but I find writing the code a bit of a challenge - hence why I’m doing these challenges on my own.

Any suggestions on the next class I should take once I’m done with the JavaScript course?

Again, thank you for any help and any advice! :slight_smile: