So there's this image uploading service called LightShot. You can easily go to any image on there with "prnt.sc/" and a 6-digit sequence of letters & numbers.
I thought it would be cool to program some code that gives you a random link to the site. Here's the code:
function func() {
let x = 'https://prnt.sc/';
let a = 1;
let b = '';
for (i = 0; i <= 5; i++) {
a = Math.floor(Math.random(16));
console.log(a);
if (a = 10) {
b += 'a';
} else if (a = 16) {
b += 'a';
} else if (a = 12) {
b += 'c';
} else if (a = 11) {
b += 'b';
} else if (a = 13) {
b += 'd';
} else if (a = 14) {
b += 'e';
} else if (a = 15) {
b += 'f';
} else {
b += a.toString();
}
} x += b;
console.log(x);
}
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="./sketch.js"></script>
</head>
<body>
<button onclick='func()'>Go</button>
</body>
</html>
Meanwhile, in the console...
➏ 0
(insert the rest here)/aaaaaa
Well, maybe it's something to do with the block of IF statements or the toString() function, but I don't know:
- How it got 0 6 out of 6 times,
- How it got all A's out of those zeros.
If someone could could fix this, please let me know.