Skip to content

Instantly share code, notes, and snippets.

@ellenbrook
Last active August 29, 2015 14:05
Show Gist options
  • Save ellenbrook/31bd0dc21f3296ec979a to your computer and use it in GitHub Desktop.
Save ellenbrook/31bd0dc21f3296ec979a to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<pre id="printTo"></pre>
<script>
function Logic(length)
{
this.input = [0];
this.length = length;
this.printTo = document.getElementById("printTo");
this.count = function count()
{
for (var i = 0; i <= this.length; i++) //loop through the input num times
{
this.printTo.innerHTML += this.input.join("")+"<br>"; //print to screen for each loop that occurs
for (var num in this.input) //cycle through each item and check it's value
{
if (this.input[num] == 0)
{
this.input.push(1); //append the appropriate value
}
else
{
this.input.push(0); //append the appropriate value
}
}
}
}
}
var deploy = new Logic(6);
deploy.count();
</script>
</body>
</html>
@ellenbrook
Copy link
Author

If anyone has any advice on how to refactor this it would be much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment