hello everyone, tell me how to make it so that when the paint runs out, the remaining letters begin to be printed in black. For
class Marker { constructor(color, percentage ) { this.color = color; this.loaded = percentage; } setPrint(text) { let index; for (let letter of text) { index = text.indexOf(letter); if (letter != " ") { if (this.loaded) { this.loaded -= 25; } else break; } } let printedText = text.substr(0, index); printedText.style.color = this.color; let change = text.substr(index); let p = document.createElement('p'); document.body.appendChild(p); let c = document.querySelector('p'); c.innerHTML = printedText + change; } } let s = new Marker('blue', 50) s.setPrint('Hello')