Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. // Write a function arrayOfLight(x) (get it? Lighthouse…? Come on!) which takes one parameter, a positive number, and returns an array containing all numbers from 0 up to and including the given number.
  2.  
  3. // Example: arrayOfLight(5) should return [0,1,2,3,4,5]
  4.  
  5. // Tips:
  6.  
  7. // An empty array can be created by simply typing [].
  8. // Adding values to an array can be done by assigning a value to an index directly via the = operator.
  9.  
  10.  
  11. function arrayOfLight(x) {
  12. var array = [];
  13. for (var i = 0; i < x; i++) {
  14. array.push(i);
  15. };
  16. return array
  17. };
  18.  
  19. arrayOfLight(5);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement