Guest User

Untitled

a guest
Nov 22nd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. /*
  12. 21/11/2017
  13. printReverse()
  14. Write a function printReverse() that takes an array as an argument and prints out the elements in the array in reverse order (don't actually revese the array itself
  15.  
  16. */
  17.  
  18. //printReverse([1,2,3,4]);
  19. //4
  20. //3
  21. //2
  22. //1
  23.  
  24.  
  25.  
  26. function printReverse (arr) {
  27. for (var i = arr.length - 1; i >= 0 ; i--) {
  28. console.log(arr[i]);
  29. }
  30. }
  31.  
  32. printReverse([5,4,3,2,1]);
  33. </script>
  34.  
  35.  
  36.  
  37. <script id="jsbin-source-javascript" type="text/javascript">/*
  38. 21/11/2017
  39. printReverse()
  40. Write a function printReverse() that takes an array as an argument and prints out the elements in the array in reverse order (don't actually revese the array itself
  41.  
  42. */
  43.  
  44. //printReverse([1,2,3,4]);
  45. //4
  46. //3
  47. //2
  48. //1
  49.  
  50.  
  51.  
  52. function printReverse (arr) {
  53. for (var i = arr.length - 1; i >= 0 ; i--) {
  54. console.log(arr[i]);
  55. }
  56. }
  57.  
  58. printReverse([5,4,3,2,1]);</script></body>
  59. </html>
Add Comment
Please, Sign In to add comment