Javascript do something before alert
<p>I want to change the color and alert a message when a button is clicked.</p>

<pre><code>function colorChange() {
  document.getElementById('word').style.color = "red";
  alert("color changed!");
}
</code></pre>

<p>I cannot change the color at the same time with an alert.</p>