Skip to content

Instantly share code, notes, and snippets.

@markbosky
Created February 9, 2023 05:06
Show Gist options
  • Save markbosky/d553a045095327a646e490491c2de717 to your computer and use it in GitHub Desktop.
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
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