let's say you had an HTML file like this:
<html> <body> <canvas id="result"></canvas> </body> </html>
as soon this line gets executed
document.writeln("#fff<br/>");
your HTML will be converted to this:
<html> <body> #fff<br/> </body> </html>
As you can see, this removes your canvas element from the DOM which will lead document.getElementById("result") to fail.
document.getElementById("result")
Now let's take a look at your code
for(const chara of encode(input)) { color += chara; if(color.length >= 6) { itr += 1; colors.push(color); document.writeln(itr+": "+color+"<br/>"); color = ""; } }
Since you called the makeColor() function with the string Example, you would get the string "6912097109112108101". This string contains chars that are greater than 6 which means your canvas element will be overwritten by your document.writeln().
makeColor()
Example
"6912097109112108101"
document.writeln()
It wasn't overriden, though, it just stayed black (which was the default color I gave it).
Did you set the color through CSS? In that case, may I see your CSS file?
I set the color using inline (element) styling.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
let's say you had an HTML file like this:
as soon this line gets executed
your HTML will be converted to this:
As you can see, this removes your canvas element from the DOM which will lead
document.getElementById("result")
to fail.Now let's take a look at your code
Since you called the
makeColor()
function with the stringExample
, you would get the string"6912097109112108101"
. This string contains chars that are greater than 6 which means your canvas element will be overwritten by yourdocument.writeln()
.It wasn't overriden, though, it just stayed black (which was the default color I gave it).
Did you set the color through CSS? In that case, may I see your CSS file?
I set the color using inline (element) styling.