Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- </html>
- <script id="jsbin-javascript">
- /*
- Task -- Print out the following pattern of numbers:
- 1
- 2
- 2
- 3
- 3
- 3
- 4
- 4
- 4
- 4
- */
- function printNumbers(limit) {
- let count = 1;
- while (count <= limit ) {
- for(let i=0; i < count; i++) {
- console.log(count)
- }
- count++
- }
- }
- printNumbers(4)
- </script>
- <script id="jsbin-source-javascript" type="text/javascript">
- /*
- Task -- Print out the following pattern of numbers:
- 1
- 2
- 2
- 3
- 3
- 3
- 4
- 4
- 4
- 4
- */
- function printNumbers(limit) {
- let count = 1;
- while (count <= limit ) {
- for(let i=0; i < count; i++) {
- console.log(count)
- }
- count++
- }
- }
- printNumbers(4)
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement