Masz błąd w HTML.
<div id="color"></div>
Div nie ma atrybutu text oraz masz źle tego div'a domkniętego.
<div id="color">...</div>
<br /><br /><br />
<div onclick="fate();">Randomness!</div>
<div onclick="restore_default_text();">Restore!</div>
const colors = ['yellow','black','pink','violet'];
var color = document.getElementById('color');
function fate() {
let number_random = Math.floor(Math.random()*4);
color.textContent = colors[number_random];
}
const copy_color = [color.textContent].slice();
function restore_default_text() {
color.textContent = copy_color;
}
lub:
<div id="color">...</div>
<br /><br /><br />
<div data-order="1">Randomness!</div>
<div data-order="2">Restore!</div>
// (...)
function fate__or__restore_default_text(e) {
if(e.target.getAttribute('data-order')==='1') {
fate();
}else if(e.target.getAttribute('data-order')==='2') {
restore_default_text();
}
}
document.addEventListener('click',fate__or__restore_default_text,false);
https://www.w3.org/TR/html5/dom.html#element-attrdef-global-data