Created
February 9, 2023 05:06
-
-
Save markbosky/d553a045095327a646e490491c2de717 to your computer and use it in GitHub Desktop.
generate and print a list of every four digit number combination excluding 0 has the first digit. Copy the list to the clipboard with each number on its own line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var combinations = []; | |
for (var i = 1000; i <= 9999; i++) { | |
if (i.toString().charAt(0) !== "0") { | |
combinations.push(i); | |
} | |
} | |
console.log(combinations.join("\n")); | |
// copy the list to the clipboard | |
var copyToClipboard = (str) => { | |
const el = document.createElement("textarea"); | |
el.value = str; | |
el.setAttribute("readonly", ""); | |
el.style.position = "absolute"; | |
el.style.left = "-9999px"; | |
document.body.appendChild(el); | |
el.select(); | |
document.execCommand("copy"); | |
document.body.removeChild(el); | |
}; | |
copyToClipboard(combinations.join("\n")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment