Body seems unclear, is it a complete sentence?
here var x will be an array and u cannot assign a value directly to array itself.
you have to select particular element from array and then assign value.
x.style.color = random_color; // like this or use loop to iterate through all elements
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (
</>) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).
whenever you use
document.getElementsByClassName("cell") method, it always result in an array of elements that have cell as class attribute. So to access any array element, you always need to use bracket notation [n]. Therefore, we will be using x or x or whatever is the requirement.
Hope this helps,