Skip to content

Instantly share code, notes, and snippets.

@reinhardt021
Created November 30, 2015 20:02
Show Gist options
  • Save reinhardt021/d7957590eb8a537fd2ee to your computer and use it in GitHub Desktop.
Save reinhardt021/d7957590eb8a537fd2ee to your computer and use it in GitHub Desktop.
Array of Light
var arrayOfLight = function (x) {
// note that x must be a positive number
// prints from 0 to that number
var result = [];
for (var i = 0; i <= x; i++) {
result.push(i);
}
return result;
};
var response = arrayOfLight(5); // = [0, 1, 2, 3, 4, 5]
console.log(response);
<!DOCTYPE HTML>
<html>
<head>
<title>Array of Light</title>
<script type="text/javascript" src="application.js"></script>
</head>
<body>
<h1>Running script now</h1>
<h2>check the console for outputs</h2>
<p>Practicing basic JavaScript in the browser.</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment