fork download
  1. #!/usr/bin/env js91
  2.  
  3. "use strict";
  4.  
  5. function fizz_buzz(n) {
  6. return [...Array(n).keys()]
  7. .map(x => {
  8. const i = x + 1;
  9. if (i % 15 === 0) {
  10. return 'FizzBuzz';
  11. } else if (i % 3 === 0) {
  12. return 'Fizz';
  13. } else if (i % 5 === 0) {
  14. return 'Buzz';
  15. } else {
  16. return i;
  17. }
  18. });
  19. }
  20.  
  21. function main(arg) {
  22. fizz_buzz(parseInt(arg)).forEach((element) => console.log(element));
  23. }
  24.  
  25. main(scriptArgs);
Runtime error #stdin #stdout #stderr 0.03s 18740KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog.js:6:14 RangeError: invalid array length
Stack:
  fizz_buzz@prog.js:6:14
  main@prog.js:22:3
  @prog.js:25:1