Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. </html>
  5. <script id="jsbin-javascript">
  6. /*
  7. Task -- Print out the following pattern of numbers:
  8. 1
  9. 2
  10. 2
  11. 3
  12. 3
  13. 3
  14. 4
  15. 4
  16. 4
  17. 4
  18. */
  19.  
  20.  
  21. function printNumbers(limit) {
  22.  
  23. let count = 1;
  24. while (count <= limit ) {
  25.  
  26. for(let i=0; i < count; i++) {
  27. console.log(count)
  28. }
  29. count++
  30. }
  31. }
  32.  
  33. printNumbers(4)
  34. </script>
  35.  
  36.  
  37. <script id="jsbin-source-javascript" type="text/javascript">
  38.  
  39. /*
  40. Task -- Print out the following pattern of numbers:
  41. 1
  42. 2
  43. 2
  44. 3
  45. 3
  46. 3
  47. 4
  48. 4
  49. 4
  50. 4
  51. */
  52.  
  53.  
  54. function printNumbers(limit) {
  55.  
  56. let count = 1;
  57. while (count <= limit ) {
  58.  
  59. for(let i=0; i < count; i++) {
  60. console.log(count)
  61. }
  62. count++
  63. }
  64. }
  65.  
  66. printNumbers(4)
  67.  
  68. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement