by dugmartin · 9y ago · 0 comments
btw, you can get pretty close to the spirit of the code with just a few more lines of Javascript:
var col = 0;
setInterval(() => {
document.body.innerHTML += String.fromCharCode(47+(Math.round(Math.random())*45)) + (++col % 80 ? "" : "<br/>")
}, 10);
or if you want to code golf you can get it into 1 line: var col = 0, fn = setInterval(() => {document.body.innerHTML += String.fromCharCode(47+(Math.round(Math.random())*45)) + (++col % 80 ? "" : "<br/>")}, 10);
You can see it in action here:https://jsfiddle.net/x5mz341z/
(edited to point to new jsfiddle with css body rules)
document.body.innerHTML += (Math.random() > 0.5 ? "\\":"/")
https://jsfiddle.net/tj1zwqat/
interesting that it renders perfect ( for me ) in chrome, and a bit of an offset in firefox
js
setInterval(() => {document.body.innerHTML += (Math.random() > 0.5 ? "╲":"╱")}, 1)
css
body { line-height:1em; max-width: 500px; word-wrap:break-word;}