From d6835ef8b7a57a3ec50774d1969038e16aa76b42 Mon Sep 17 00:00:00 2001 From: Naomi Date: Wed, 17 Apr 2024 09:29:14 -0700 Subject: [PATCH] feat: new introductory javascript project (#54305) Co-authored-by: Sem Bauke Co-authored-by: Jessica Wilkins <67210629+jdwilkin4@users.noreply.github.com> Co-authored-by: Kolade Chris <65571316+Ksound22@users.noreply.github.com> --- client/i18n/locales/english/intro.json | 7 + .../index.md | 10 + .../build-a-cash-register-project/meta.json | 4 +- .../meta.json | 4 +- .../meta.json | 4 +- .../meta.json | 4 +- .../meta.json | 4 +- .../meta.json | 4 +- .../meta.json | 4 +- .../meta.json | 4 +- .../meta.json | 4 +- .../meta.json | 4 +- .../meta.json | 4 +- .../meta.json | 4 +- .../meta.json | 4 +- .../meta.json | 4 +- .../meta.json | 2 +- .../meta.json | 4 +- .../meta.json | 453 ++++++++++++++++++ .../meta.json | 4 +- .../meta.json | 4 +- .../meta.json | 4 +- .../meta.json | 4 +- .../meta.json | 4 +- .../660ee6e3a242da6bd579de69.md | 60 +++ .../660eebd83100d37862268781.md | 54 +++ .../660ef0f7c4b8e68ccd1f0786.md | 57 +++ .../660ef19b95d3308e7dd31bb6.md | 57 +++ .../660ef31a5be625914a0102cd.md | 64 +++ .../660ef5105b8ba095307a0e50.md | 44 ++ .../660ef55dd468079679ee0092.md | 53 ++ .../660ef5c1904955978a986a5c.md | 46 ++ .../660ef6355e8f5a9e67fe5f46.md | 42 ++ .../660ef857f2806aa626d29d17.md | 42 ++ .../660f033cf051ebb50ea3bf48.md | 53 ++ .../660f039ff313dbb696b007ca.md | 48 ++ .../660f061d259bbebc37461080.md | 59 +++ .../660f07d231941bc11719f664.md | 71 +++ .../660f09a2694b59c3a10ee304.md | 45 ++ .../660f0a55847d6cc485f29ba5.md | 52 ++ .../660f0c34aad72dc712b97624.md | 61 +++ .../660f0da9bf1035c9097af20a.md | 55 +++ .../660f0ee51d7460ce88cd248d.md | 61 +++ .../660f0f980e98e8cf77f1ce31.md | 38 ++ .../660f165270622fd4ec0da3f7.md | 65 +++ .../660f17294346b7d69e79db3d.md | 32 ++ .../660f17d4e9f227d86e834abd.md | 67 +++ .../660f18f059fe0fda192ce394.md | 56 +++ .../660f1a00ac619ddc1e259a66.md | 52 ++ .../660f1b6e60bd9edf902c81fd.md | 50 ++ .../660f1bf673487ae0bb25b900.md | 46 ++ .../660f1cedf3676fe26122ebf6.md | 54 +++ .../660f1e3f047bf4e403268713.md | 50 ++ .../660f20473aef47e9b8c9afc6.md | 44 ++ .../660f207334fabaeac3269c38.md | 82 ++++ .../660f229d2dbe09ef2954a4a1.md | 58 +++ .../660f23b53db70af0f2620e78.md | 68 +++ .../660f255022991ef34ed0ee88.md | 50 ++ .../660f280dda5040f707c76b4a.md | 63 +++ .../660f2a70ad6225fa503e71c3.md | 46 ++ .../660f2b6fd54ac1fc142804dd.md | 75 +++ .../660f2eccfe3f820304af1b39.md | 67 +++ .../660f2fbd45b520046cac68e8.md | 81 ++++ .../660f34626216270c682e2f7b.md | 67 +++ .../660f34e99571070d56d2f231.md | 67 +++ .../660f359af3e32e0f1a6880b7.md | 60 +++ .../660f374d532dc41189cc9cc2.md | 64 +++ .../660f383d4c772c12ff59904b.md | 63 +++ .../660f38c34a4de6141c0c369f.md | 61 +++ .../660f3915b41a441537ec9f5e.md | 59 +++ .../660f39b444fd6f16d1e49c1f.md | 48 ++ .../660f3b664421471aa595170f.md | 54 +++ .../660f3ba3cceef11b6ba08b59.md | 58 +++ .../660f3ce51f70571e1c5227c8.md | 57 +++ .../660f3dd626be3a1ffe27e5d1.md | 66 +++ .../660f415b76859a2736771607.md | 71 +++ .../660f4377a359972c521d3f4b.md | 53 ++ .../660f4455f457ef2e3ec6920f.md | 53 ++ .../660f447efc0e722f016c1be0.md | 57 +++ .../660f44f10ea40f300b896a5e.md | 77 +++ .../660f455b044d3230ed971e98.md | 65 +++ .../660f45ccf4ca5c31f253005a.md | 56 +++ .../660f46460f9c36330ebc07d8.md | 61 +++ .../660f46b9c417a8341729a3ab.md | 59 +++ .../660f4774e3e0df35a68bb5f2.md | 76 +++ .../660f47afe4c98536715d5fa4.md | 60 +++ .../660f487dc0c8fa38084f9754.md | 64 +++ .../660f48a419b40238e2b8b4d5.md | 57 +++ .../660f48e1d3682f39e81843c4.md | 58 +++ .../660f4934fb48f63abd5ae371.md | 58 +++ .../660f4990b1caa03b9dc97a43.md | 60 +++ .../660f49e32001983c90b75850.md | 61 +++ .../660f4a1472f8e63d76162ce5.md | 75 +++ .../660f4a83373de83ea101685f.md | 57 +++ .../660f4ae5b3924c3fc3373973.md | 57 +++ .../660f4b33e2a3364094ecb540.md | 76 +++ .../660f4b641290da41b2cf0dd9.md | 63 +++ .../660f4c3b01c44743719c99e4.md | 63 +++ .../660f4cde8dd305450514a1cb.md | 63 +++ .../660f4cffb1459d45e34902d1.md | 77 +++ .../660f4de78f775e480ba2e451.md | 86 ++++ .../660f4e74f7fd3f4a99ac2e50.md | 91 ++++ .../660f4efcb8068e4cb470dca1.md | 82 ++++ .../660f4f79e2a82a4e92290f44.md | 78 +++ .../660f505d02b2bd513a1c3468.md | 76 +++ .../660f50a21fe7645252804f2b.md | 64 +++ .../660f5179b3b0ca558f6b4d4f.md | 69 +++ .../660f51f1df0a8757934a5796.md | 59 +++ .../660f530d6e33d159e1bf4947.md | 77 +++ .../660f535ec33a285b33af3774.md | 78 +++ .../660f53ad3d39175c5d4335ac.md | 74 +++ .../660f540c2176ea5dec01306d.md | 96 ++++ .../6610b741b54b90f0c0fb3d58.md | 55 +++ .../6610b8017d1671f2814e8c77.md | 40 ++ .../6610b8f6a98d25f4d485a94d.md | 54 +++ .../6610b9f7619764fad5fd516d.md | 58 +++ .../6610bbed59bc2a0194d85533.md | 53 ++ .../6610bf6fa14d700beed1b109.md | 63 +++ .../6610c105bbdacc114d6cdc44.md | 63 +++ .../6610c16c4fa0df12c0e30675.md | 62 +++ .../6610c1d97b1671140f95cfbb.md | 55 +++ .../6610c21b3ef82015573ffbbe.md | 65 +++ .../6610c2d8d67563174fcf96dc.md | 61 +++ .../6610c424b7119919b62932f4.md | 51 ++ .../6610c48c4ea0891afa7c4696.md | 60 +++ .../6610c538372aa61cc0f5b122.md | 69 +++ .../6610c6541c82551f95e765ab.md | 61 +++ .../6610c71600966a2191d3a64a.md | 55 +++ .../6610c77d50636722e5b6be17.md | 53 ++ .../6610c83b52583e245a079217.md | 63 +++ .../6610c87eac0f0b256d7b037e.md | 57 +++ .../6610c8cfe4cf4d278e35c156.md | 54 +++ .../661483051820c3c1ab4595e0.md | 66 +++ .../english/comments-to-not-translate.json | 5 +- curriculum/dictionaries/english/comments.json | 3 +- 135 files changed, 7134 insertions(+), 43 deletions(-) create mode 100644 client/src/pages/learn/javascript-algorithms-and-data-structures-v8/learn-introductory-javascript-by-building-a-pyramid-generator/index.md create mode 100644 curriculum/challenges/_meta/learn-introductory-javascript-by-building-a-pyramid-generator/meta.json create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ee6e3a242da6bd579de69.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660eebd83100d37862268781.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef0f7c4b8e68ccd1f0786.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef19b95d3308e7dd31bb6.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef31a5be625914a0102cd.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef5105b8ba095307a0e50.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef55dd468079679ee0092.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef5c1904955978a986a5c.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef6355e8f5a9e67fe5f46.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef857f2806aa626d29d17.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f033cf051ebb50ea3bf48.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f039ff313dbb696b007ca.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f061d259bbebc37461080.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f07d231941bc11719f664.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f09a2694b59c3a10ee304.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0a55847d6cc485f29ba5.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0c34aad72dc712b97624.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0da9bf1035c9097af20a.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0ee51d7460ce88cd248d.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0f980e98e8cf77f1ce31.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f165270622fd4ec0da3f7.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f17294346b7d69e79db3d.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f17d4e9f227d86e834abd.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f18f059fe0fda192ce394.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1a00ac619ddc1e259a66.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1b6e60bd9edf902c81fd.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1bf673487ae0bb25b900.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1cedf3676fe26122ebf6.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1e3f047bf4e403268713.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f20473aef47e9b8c9afc6.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f207334fabaeac3269c38.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f229d2dbe09ef2954a4a1.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f23b53db70af0f2620e78.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f255022991ef34ed0ee88.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f280dda5040f707c76b4a.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f2a70ad6225fa503e71c3.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f2b6fd54ac1fc142804dd.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f2eccfe3f820304af1b39.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f2fbd45b520046cac68e8.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f34626216270c682e2f7b.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f34e99571070d56d2f231.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f359af3e32e0f1a6880b7.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f374d532dc41189cc9cc2.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f383d4c772c12ff59904b.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f38c34a4de6141c0c369f.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3915b41a441537ec9f5e.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f39b444fd6f16d1e49c1f.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3b664421471aa595170f.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3ba3cceef11b6ba08b59.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3ce51f70571e1c5227c8.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3dd626be3a1ffe27e5d1.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f415b76859a2736771607.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4377a359972c521d3f4b.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4455f457ef2e3ec6920f.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f447efc0e722f016c1be0.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f44f10ea40f300b896a5e.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f455b044d3230ed971e98.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f45ccf4ca5c31f253005a.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f46460f9c36330ebc07d8.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f46b9c417a8341729a3ab.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4774e3e0df35a68bb5f2.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f47afe4c98536715d5fa4.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f487dc0c8fa38084f9754.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f48a419b40238e2b8b4d5.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f48e1d3682f39e81843c4.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4934fb48f63abd5ae371.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4990b1caa03b9dc97a43.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f49e32001983c90b75850.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4a1472f8e63d76162ce5.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4a83373de83ea101685f.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4ae5b3924c3fc3373973.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4b33e2a3364094ecb540.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4b641290da41b2cf0dd9.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4c3b01c44743719c99e4.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4cde8dd305450514a1cb.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4cffb1459d45e34902d1.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4de78f775e480ba2e451.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4e74f7fd3f4a99ac2e50.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4efcb8068e4cb470dca1.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4f79e2a82a4e92290f44.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f505d02b2bd513a1c3468.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f50a21fe7645252804f2b.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f5179b3b0ca558f6b4d4f.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f51f1df0a8757934a5796.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f530d6e33d159e1bf4947.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f535ec33a285b33af3774.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f53ad3d39175c5d4335ac.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f540c2176ea5dec01306d.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610b741b54b90f0c0fb3d58.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610b8017d1671f2814e8c77.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610b8f6a98d25f4d485a94d.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610b9f7619764fad5fd516d.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610bbed59bc2a0194d85533.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610bf6fa14d700beed1b109.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c105bbdacc114d6cdc44.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c16c4fa0df12c0e30675.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c1d97b1671140f95cfbb.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c21b3ef82015573ffbbe.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c2d8d67563174fcf96dc.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c424b7119919b62932f4.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c48c4ea0891afa7c4696.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c538372aa61cc0f5b122.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c6541c82551f95e765ab.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c71600966a2191d3a64a.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c77d50636722e5b6be17.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c83b52583e245a079217.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c87eac0f0b256d7b037e.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c8cfe4cf4d278e35c156.md create mode 100644 curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/661483051820c3c1ab4595e0.md diff --git a/client/i18n/locales/english/intro.json b/client/i18n/locales/english/intro.json index 1b35677c4c9..096488d2426 100644 --- a/client/i18n/locales/english/intro.json +++ b/client/i18n/locales/english/intro.json @@ -458,6 +458,13 @@ "Recursion is a programming concept where a function calls itself. This can reduce a complex problem into simpler sub-problems, until they become straightforward to solve.", "In this project, you’ll build a decimal-to-binary converter using JavaScript. You’ll learn the fundamental concepts of recursion, explore the call stack, and build out a visual representation of the recursion process through an animation." ] + }, + "learn-introductory-javascript-by-building-a-pyramid-generator": { + "title": "Learn Introductory JavaScript by Building a Pyramid Generator", + "intro": [ + "JavaScript is a powerful scripting language that you can use to make web pages interactive. It's one of the core technologies of the web, along with HTML and CSS. All modern browsers support JavaScript.", + "In this practice project, you'll learn fundamental programming concepts in JavaScript by coding your own Pyramid Generator. You'll learn how to work with arrays, strings, functions, loops, if/else statements, and more." + ] } } }, diff --git a/client/src/pages/learn/javascript-algorithms-and-data-structures-v8/learn-introductory-javascript-by-building-a-pyramid-generator/index.md b/client/src/pages/learn/javascript-algorithms-and-data-structures-v8/learn-introductory-javascript-by-building-a-pyramid-generator/index.md new file mode 100644 index 00000000000..397047acecc --- /dev/null +++ b/client/src/pages/learn/javascript-algorithms-and-data-structures-v8/learn-introductory-javascript-by-building-a-pyramid-generator/index.md @@ -0,0 +1,10 @@ +--- +title: Introduction to the Learn Introductory JavaScript by Building a Pyramid Generator +block: learn-introductory-javascript-by-building-a-pyramid-generator +superBlock: javascript-algorithms-and-data-structures-v8 +isBeta: true +--- + +## Introduction to the Learn Introductory JavaScript by Building a Pyramid Generator + +This is a test for the new project-based curriculum. diff --git a/curriculum/challenges/_meta/build-a-cash-register-project/meta.json b/curriculum/challenges/_meta/build-a-cash-register-project/meta.json index cf907663bed..dadbff757ab 100644 --- a/curriculum/challenges/_meta/build-a-cash-register-project/meta.json +++ b/curriculum/challenges/_meta/build-a-cash-register-project/meta.json @@ -4,7 +4,7 @@ "dashedName": "build-a-cash-register-project", "usesMultifileEditor": true, "helpCategory": "JavaScript", - "order": 17, + "order": 18, "time": "30 hours", "template": "", "required": [], @@ -15,4 +15,4 @@ "title": "Build a Cash Register" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/build-a-palindrome-checker-project/meta.json b/curriculum/challenges/_meta/build-a-palindrome-checker-project/meta.json index bd125b4f9e5..b4a53add748 100644 --- a/curriculum/challenges/_meta/build-a-palindrome-checker-project/meta.json +++ b/curriculum/challenges/_meta/build-a-palindrome-checker-project/meta.json @@ -4,7 +4,7 @@ "dashedName": "build-a-palindrome-checker-project", "usesMultifileEditor": true, "helpCategory": "JavaScript", - "order": 4, + "order": 5, "time": "30 hours", "template": "", "required": [], @@ -15,4 +15,4 @@ "title": "Build a Palindrome Checker" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/build-a-pokemon-search-app-project/meta.json b/curriculum/challenges/_meta/build-a-pokemon-search-app-project/meta.json index 0b1acb0d6ea..ee22a4db890 100644 --- a/curriculum/challenges/_meta/build-a-pokemon-search-app-project/meta.json +++ b/curriculum/challenges/_meta/build-a-pokemon-search-app-project/meta.json @@ -4,7 +4,7 @@ "dashedName": "build-a-pokemon-search-app-project", "usesMultifileEditor": true, "helpCategory": "JavaScript", - "order": 20, + "order": 21, "time": "30 hours", "template": "", "required": [], @@ -15,4 +15,4 @@ "title": "Build a Pokémon Search App Project" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/build-a-roman-numeral-converter-project/meta.json b/curriculum/challenges/_meta/build-a-roman-numeral-converter-project/meta.json index 1013c173fb8..5c9c12e848b 100644 --- a/curriculum/challenges/_meta/build-a-roman-numeral-converter-project/meta.json +++ b/curriculum/challenges/_meta/build-a-roman-numeral-converter-project/meta.json @@ -4,7 +4,7 @@ "dashedName": "build-a-roman-numeral-converter-project", "usesMultifileEditor": true, "helpCategory": "JavaScript", - "order": 8, + "order": 9, "time": "30 hours", "template": "", "required": [], @@ -15,4 +15,4 @@ "title": "Build a Roman Numeral Converter" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/build-a-telephone-number-validator-project/meta.json b/curriculum/challenges/_meta/build-a-telephone-number-validator-project/meta.json index 6f068975dc3..ff310353aab 100644 --- a/curriculum/challenges/_meta/build-a-telephone-number-validator-project/meta.json +++ b/curriculum/challenges/_meta/build-a-telephone-number-validator-project/meta.json @@ -4,7 +4,7 @@ "dashedName": "build-a-telephone-number-validator-project", "usesMultifileEditor": true, "helpCategory": "JavaScript", - "order": 13, + "order": 14, "time": "30 hours", "template": "", "required": [], @@ -15,4 +15,4 @@ "title": "Build a Telephone Number Validator" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/learn-advanced-array-methods-by-building-a-statistics-calculator/meta.json b/curriculum/challenges/_meta/learn-advanced-array-methods-by-building-a-statistics-calculator/meta.json index 19d22067a1e..6c584c43673 100644 --- a/curriculum/challenges/_meta/learn-advanced-array-methods-by-building-a-statistics-calculator/meta.json +++ b/curriculum/challenges/_meta/learn-advanced-array-methods-by-building-a-statistics-calculator/meta.json @@ -5,7 +5,7 @@ "hasEditableBoundaries": true, "dashedName": "learn-advanced-array-methods-by-building-a-statistics-calculator", "helpCategory": "JavaScript", - "order": 11, + "order": 12, "time": "5 hours", "template": "", "required": [], @@ -234,4 +234,4 @@ "title": "Step 55" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/meta.json b/curriculum/challenges/_meta/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/meta.json index 61b1d259e7d..9ac3490844c 100644 --- a/curriculum/challenges/_meta/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/meta.json +++ b/curriculum/challenges/_meta/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/meta.json @@ -5,7 +5,7 @@ "hasEditableBoundaries": true, "dashedName": "learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard", "helpCategory": "JavaScript", - "order": 19, + "order": 20, "time": "5 hours", "template": "", "required": [], @@ -280,4 +280,4 @@ "title": "Step 67" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/learn-basic-algorithmic-thinking-by-building-a-number-sorter/meta.json b/curriculum/challenges/_meta/learn-basic-algorithmic-thinking-by-building-a-number-sorter/meta.json index f8224b974c2..43abe93c592 100644 --- a/curriculum/challenges/_meta/learn-basic-algorithmic-thinking-by-building-a-number-sorter/meta.json +++ b/curriculum/challenges/_meta/learn-basic-algorithmic-thinking-by-building-a-number-sorter/meta.json @@ -5,7 +5,7 @@ "hasEditableBoundaries": true, "dashedName": "learn-basic-algorithmic-thinking-by-building-a-number-sorter", "helpCategory": "JavaScript", - "order": 10, + "order": 11, "time": "5 hours", "template": "", "required": [], @@ -182,4 +182,4 @@ "title": "Step 42" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/learn-basic-javascript-by-building-a-role-playing-game/meta.json b/curriculum/challenges/_meta/learn-basic-javascript-by-building-a-role-playing-game/meta.json index 0616255d421..027f562e1d2 100644 --- a/curriculum/challenges/_meta/learn-basic-javascript-by-building-a-role-playing-game/meta.json +++ b/curriculum/challenges/_meta/learn-basic-javascript-by-building-a-role-playing-game/meta.json @@ -5,7 +5,7 @@ "hasEditableBoundaries": true, "dashedName": "learn-basic-javascript-by-building-a-role-playing-game", "helpCategory": "JavaScript", - "order": 0, + "order": 1, "time": "2 hours", "template": "", "required": [], @@ -729,4 +729,4 @@ "title": "Step 179" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/learn-basic-oop-by-building-a-shopping-cart/meta.json b/curriculum/challenges/_meta/learn-basic-oop-by-building-a-shopping-cart/meta.json index 52ca0cb7b35..783576658b1 100644 --- a/curriculum/challenges/_meta/learn-basic-oop-by-building-a-shopping-cart/meta.json +++ b/curriculum/challenges/_meta/learn-basic-oop-by-building-a-shopping-cart/meta.json @@ -5,7 +5,7 @@ "hasEditableBoundaries": true, "dashedName": "learn-basic-oop-by-building-a-shopping-cart", "helpCategory": "JavaScript", - "order": 14, + "order": 15, "time": "5 hours", "template": "", "required": [], @@ -254,4 +254,4 @@ "title": "Step 60" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/learn-basic-string-and-array-methods-by-building-a-music-player/meta.json b/curriculum/challenges/_meta/learn-basic-string-and-array-methods-by-building-a-music-player/meta.json index 2eaa5d48140..407e0317a19 100644 --- a/curriculum/challenges/_meta/learn-basic-string-and-array-methods-by-building-a-music-player/meta.json +++ b/curriculum/challenges/_meta/learn-basic-string-and-array-methods-by-building-a-music-player/meta.json @@ -4,7 +4,7 @@ "usesMultifileEditor": true, "hasEditableBoundaries": true, "dashedName": "learn-basic-string-and-array-methods-by-building-a-music-player", - "order": 2, + "order": 3, "time": "5 hours", "template": "", "required": [], @@ -410,4 +410,4 @@ } ], "helpCategory": "JavaScript" -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/learn-fetch-and-promises-by-building-an-fcc-authors-page/meta.json b/curriculum/challenges/_meta/learn-fetch-and-promises-by-building-an-fcc-authors-page/meta.json index 9b13cde0f6f..64f34bb16d5 100644 --- a/curriculum/challenges/_meta/learn-fetch-and-promises-by-building-an-fcc-authors-page/meta.json +++ b/curriculum/challenges/_meta/learn-fetch-and-promises-by-building-an-fcc-authors-page/meta.json @@ -5,7 +5,7 @@ "hasEditableBoundaries": true, "dashedName": "learn-fetch-and-promises-by-building-an-fcc-authors-page", "helpCategory": "JavaScript", - "order": 18, + "order": 19, "time": "5 hours", "template": "", "required": [], @@ -130,4 +130,4 @@ "title": "Step 29" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/learn-form-validation-by-building-a-calorie-counter/meta.json b/curriculum/challenges/_meta/learn-form-validation-by-building-a-calorie-counter/meta.json index c9764a3a2c2..c729392dc5a 100644 --- a/curriculum/challenges/_meta/learn-form-validation-by-building-a-calorie-counter/meta.json +++ b/curriculum/challenges/_meta/learn-form-validation-by-building-a-calorie-counter/meta.json @@ -5,7 +5,7 @@ "hasEditableBoundaries": true, "dashedName": "learn-form-validation-by-building-a-calorie-counter", "helpCategory": "JavaScript", - "order": 1, + "order": 2, "time": "2 hours", "template": "", "required": [], @@ -396,4 +396,4 @@ "title": "Step 96" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/learn-functional-programming-by-building-a-spreadsheet/meta.json b/curriculum/challenges/_meta/learn-functional-programming-by-building-a-spreadsheet/meta.json index fe1aef5fb5b..27d34df304f 100644 --- a/curriculum/challenges/_meta/learn-functional-programming-by-building-a-spreadsheet/meta.json +++ b/curriculum/challenges/_meta/learn-functional-programming-by-building-a-spreadsheet/meta.json @@ -5,7 +5,7 @@ "hasEditableBoundaries": true, "dashedName": "learn-functional-programming-by-building-a-spreadsheet", "helpCategory": "JavaScript", - "order": 12, + "order": 13, "time": "2 hours", "template": "", "required": [], @@ -426,4 +426,4 @@ "title": "Step 103" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/meta.json b/curriculum/challenges/_meta/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/meta.json index 1e33280b160..593489786c6 100644 --- a/curriculum/challenges/_meta/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/meta.json +++ b/curriculum/challenges/_meta/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/meta.json @@ -4,7 +4,7 @@ "usesMultifileEditor": true, "hasEditableBoundaries": true, "dashedName": "learn-intermediate-algorithmic-thinking-by-building-a-dice-game", - "order": 16, + "order": 17, "time": "5 hours", "template": "", "required": [], diff --git a/curriculum/challenges/_meta/learn-intermediate-oop-by-building-a-platformer-game/meta.json b/curriculum/challenges/_meta/learn-intermediate-oop-by-building-a-platformer-game/meta.json index 000ff184f34..b123c8c40f4 100644 --- a/curriculum/challenges/_meta/learn-intermediate-oop-by-building-a-platformer-game/meta.json +++ b/curriculum/challenges/_meta/learn-intermediate-oop-by-building-a-platformer-game/meta.json @@ -5,7 +5,7 @@ "hasEditableBoundaries": true, "dashedName": "learn-intermediate-oop-by-building-a-platformer-game", "helpCategory": "JavaScript", - "order": 15, + "order": 16, "time": "5 hours", "template": "", "required": [], @@ -484,4 +484,4 @@ "title": "Step 117" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/learn-introductory-javascript-by-building-a-pyramid-generator/meta.json b/curriculum/challenges/_meta/learn-introductory-javascript-by-building-a-pyramid-generator/meta.json new file mode 100644 index 00000000000..a8aabe21389 --- /dev/null +++ b/curriculum/challenges/_meta/learn-introductory-javascript-by-building-a-pyramid-generator/meta.json @@ -0,0 +1,453 @@ +{ + "name": "Learn Introductory JavaScript by Building a Pyramid Generator", + "isUpcomingChange": false, + "usesMultifileEditor": true, + "hasEditableBoundaries": true, + "dashedName": "learn-introductory-javascript-by-building-a-pyramid-generator", + "order": 0, + "time": "5 hours", + "template": "", + "required": [], + "superBlock": "javascript-algorithms-and-data-structures-v8", + "superOrder": 4, + "isBeta": true, + "challengeOrder": [ + { + "id": "660ee6e3a242da6bd579de69", + "title": "Step 1" + }, + { + "id": "660eebd83100d37862268781", + "title": "Step 2" + }, + { + "id": "660ef0f7c4b8e68ccd1f0786", + "title": "Step 3" + }, + { + "id": "660ef19b95d3308e7dd31bb6", + "title": "Step 4" + }, + { + "id": "660ef31a5be625914a0102cd", + "title": "Step 5" + }, + { + "id": "660ef5105b8ba095307a0e50", + "title": "Step 6" + }, + { + "id": "6610b741b54b90f0c0fb3d58", + "title": "Step 7" + }, + { + "id": "6610b8017d1671f2814e8c77", + "title": "Step 8" + }, + { + "id": "6610b8f6a98d25f4d485a94d", + "title": "Step 9" + }, + { + "id": "6610b9f7619764fad5fd516d", + "title": "Step 10" + }, + { + "id": "660ef55dd468079679ee0092", + "title": "Step 11" + }, + { + "id": "660ef5c1904955978a986a5c", + "title": "Step 12" + }, + { + "id": "660ef6355e8f5a9e67fe5f46", + "title": "Step 13" + }, + { + "id": "660ef857f2806aa626d29d17", + "title": "Step 14" + }, + { + "id": "660f033cf051ebb50ea3bf48", + "title": "Step 15" + }, + { + "id": "660f039ff313dbb696b007ca", + "title": "Step 16" + }, + { + "id": "660f061d259bbebc37461080", + "title": "Step 17" + }, + { + "id": "660f07d231941bc11719f664", + "title": "Step 18" + }, + { + "id": "6610bbed59bc2a0194d85533", + "title": "Step 19" + }, + { + "id": "660f09a2694b59c3a10ee304", + "title": "Step 20" + }, + { + "id": "660f0a55847d6cc485f29ba5", + "title": "Step 21" + }, + { + "id": "660f0c34aad72dc712b97624", + "title": "Step 22" + }, + { + "id": "660f0da9bf1035c9097af20a", + "title": "Step 23" + }, + { + "id": "660f0ee51d7460ce88cd248d", + "title": "Step 24" + }, + { + "id": "660f0f980e98e8cf77f1ce31", + "title": "Step 25" + }, + { + "id": "660f165270622fd4ec0da3f7", + "title": "Step 26" + }, + { + "id": "660f17294346b7d69e79db3d", + "title": "Step 27" + }, + { + "id": "660f17d4e9f227d86e834abd", + "title": "Step 28" + }, + { + "id": "660f18f059fe0fda192ce394", + "title": "Step 29" + }, + { + "id": "660f1a00ac619ddc1e259a66", + "title": "Step 30" + }, + { + "id": "660f1b6e60bd9edf902c81fd", + "title": "Step 31" + }, + { + "id": "660f1bf673487ae0bb25b900", + "title": "Step 32" + }, + { + "id": "660f1cedf3676fe26122ebf6", + "title": "Step 33" + }, + { + "id": "660f1e3f047bf4e403268713", + "title": "Step 34" + }, + { + "id": "660f20473aef47e9b8c9afc6", + "title": "Step 35" + }, + { + "id": "660f207334fabaeac3269c38", + "title": "Step 36" + }, + { + "id": "660f229d2dbe09ef2954a4a1", + "title": "Step 37" + }, + { + "id": "660f23b53db70af0f2620e78", + "title": "Step 38" + }, + { + "id": "660f255022991ef34ed0ee88", + "title": "Step 39" + }, + { + "id": "660f280dda5040f707c76b4a", + "title": "Step 40" + }, + { + "id": "660f2a70ad6225fa503e71c3", + "title": "Step 41" + }, + { + "id": "660f2b6fd54ac1fc142804dd", + "title": "Step 42" + }, + { + "id": "6610c105bbdacc114d6cdc44", + "title": "Step 43" + }, + { + "id": "6610c16c4fa0df12c0e30675", + "title": "Step 44" + }, + { + "id": "6610c1d97b1671140f95cfbb", + "title": "Step 45" + }, + { + "id": "6610c21b3ef82015573ffbbe", + "title": "Step 46" + }, + { + "id": "6610c2d8d67563174fcf96dc", + "title": "Step 47" + }, + { + "id": "6610c424b7119919b62932f4", + "title": "Step 48" + }, + { + "id": "6610c48c4ea0891afa7c4696", + "title": "Step 49" + }, + { + "id": "6610c538372aa61cc0f5b122", + "title": "Step 50" + }, + { + "id": "6610c6541c82551f95e765ab", + "title": "Step 51" + }, + { + "id": "6610c71600966a2191d3a64a", + "title": "Step 52" + }, + { + "id": "6610c77d50636722e5b6be17", + "title": "Step 53" + }, + { + "id": "6610c83b52583e245a079217", + "title": "Step 54" + }, + { + "id": "6610c87eac0f0b256d7b037e", + "title": "Step 55" + }, + { + "id": "6610c8cfe4cf4d278e35c156", + "title": "Step 56" + }, + { + "id": "660f2eccfe3f820304af1b39", + "title": "Step 57" + }, + { + "id": "660f2fbd45b520046cac68e8", + "title": "Step 58" + }, + { + "id": "660f34626216270c682e2f7b", + "title": "Step 59" + }, + { + "id": "660f34e99571070d56d2f231", + "title": "Step 60" + }, + { + "id": "660f359af3e32e0f1a6880b7", + "title": "Step 61" + }, + { + "id": "660f374d532dc41189cc9cc2", + "title": "Step 62" + }, + { + "id": "660f383d4c772c12ff59904b", + "title": "Step 63" + }, + { + "id": "660f38c34a4de6141c0c369f", + "title": "Step 64" + }, + { + "id": "660f3915b41a441537ec9f5e", + "title": "Step 65" + }, + { + "id": "660f39b444fd6f16d1e49c1f", + "title": "Step 66" + }, + { + "id": "660f3b664421471aa595170f", + "title": "Step 67" + }, + { + "id": "660f3ba3cceef11b6ba08b59", + "title": "Step 68" + }, + { + "id": "660f3ce51f70571e1c5227c8", + "title": "Step 69" + }, + { + "id": "660f3dd626be3a1ffe27e5d1", + "title": "Step 70" + }, + { + "id": "660f415b76859a2736771607", + "title": "Step 71" + }, + { + "id": "660f4377a359972c521d3f4b", + "title": "Step 72" + }, + { + "id": "660f4455f457ef2e3ec6920f", + "title": "Step 73" + }, + { + "id": "660f447efc0e722f016c1be0", + "title": "Step 74" + }, + { + "id": "660f44f10ea40f300b896a5e", + "title": "Step 75" + }, + { + "id": "660f455b044d3230ed971e98", + "title": "Step 76" + }, + { + "id": "660f45ccf4ca5c31f253005a", + "title": "Step 77" + }, + { + "id": "6610bf6fa14d700beed1b109", + "title": "Step 78" + }, + { + "id": "660f46460f9c36330ebc07d8", + "title": "Step 79" + }, + { + "id": "660f46b9c417a8341729a3ab", + "title": "Step 80" + }, + { + "id": "660f4774e3e0df35a68bb5f2", + "title": "Step 81" + }, + { + "id": "660f47afe4c98536715d5fa4", + "title": "Step 82" + }, + { + "id": "660f487dc0c8fa38084f9754", + "title": "Step 83" + }, + { + "id": "660f48a419b40238e2b8b4d5", + "title": "Step 84" + }, + { + "id": "660f48e1d3682f39e81843c4", + "title": "Step 85" + }, + { + "id": "660f4934fb48f63abd5ae371", + "title": "Step 86" + }, + { + "id": "661483051820c3c1ab4595e0", + "title": "Step 87" + }, + { + "id": "660f4990b1caa03b9dc97a43", + "title": "Step 88" + }, + { + "id": "660f49e32001983c90b75850", + "title": "Step 89" + }, + { + "id": "660f4a1472f8e63d76162ce5", + "title": "Step 90" + }, + { + "id": "660f4a83373de83ea101685f", + "title": "Step 91" + }, + { + "id": "660f4ae5b3924c3fc3373973", + "title": "Step 92" + }, + { + "id": "660f4b33e2a3364094ecb540", + "title": "Step 93" + }, + { + "id": "660f4b641290da41b2cf0dd9", + "title": "Step 94" + }, + { + "id": "660f4c3b01c44743719c99e4", + "title": "Step 95" + }, + { + "id": "660f4cde8dd305450514a1cb", + "title": "Step 96" + }, + { + "id": "660f4cffb1459d45e34902d1", + "title": "Step 97" + }, + { + "id": "660f4de78f775e480ba2e451", + "title": "Step 98" + }, + { + "id": "660f4e74f7fd3f4a99ac2e50", + "title": "Step 99" + }, + { + "id": "660f4efcb8068e4cb470dca1", + "title": "Step 100" + }, + { + "id": "660f4f79e2a82a4e92290f44", + "title": "Step 101" + }, + { + "id": "660f505d02b2bd513a1c3468", + "title": "Step 102" + }, + { + "id": "660f50a21fe7645252804f2b", + "title": "Step 103" + }, + { + "id": "660f5179b3b0ca558f6b4d4f", + "title": "Step 104" + }, + { + "id": "660f51f1df0a8757934a5796", + "title": "Step 105" + }, + { + "id": "660f530d6e33d159e1bf4947", + "title": "Step 106" + }, + { + "id": "660f535ec33a285b33af3774", + "title": "Step 107" + }, + { + "id": "660f53ad3d39175c5d4335ac", + "title": "Step 108" + }, + { + "id": "660f540c2176ea5dec01306d", + "title": "Step 109" + } + ], + "helpCategory": "JavaScript" +} diff --git a/curriculum/challenges/_meta/learn-localstorage-by-building-a-todo-app/meta.json b/curriculum/challenges/_meta/learn-localstorage-by-building-a-todo-app/meta.json index 1f8119a7d3f..18c5596ec2f 100644 --- a/curriculum/challenges/_meta/learn-localstorage-by-building-a-todo-app/meta.json +++ b/curriculum/challenges/_meta/learn-localstorage-by-building-a-todo-app/meta.json @@ -4,7 +4,7 @@ "usesMultifileEditor": true, "hasEditableBoundaries": true, "dashedName": "learn-localstorage-by-building-a-todo-app", - "order": 6, + "order": 7, "time": "5 hours", "template": "", "required": [], @@ -274,4 +274,4 @@ } ], "helpCategory": "JavaScript" -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/learn-modern-javascript-methods-by-building-football-team-cards/meta.json b/curriculum/challenges/_meta/learn-modern-javascript-methods-by-building-football-team-cards/meta.json index feac82f5f70..b123b93b320 100644 --- a/curriculum/challenges/_meta/learn-modern-javascript-methods-by-building-football-team-cards/meta.json +++ b/curriculum/challenges/_meta/learn-modern-javascript-methods-by-building-football-team-cards/meta.json @@ -5,7 +5,7 @@ "hasEditableBoundaries": true, "dashedName": "learn-modern-javascript-methods-by-building-football-team-cards", "helpCategory": "JavaScript", - "order": 5, + "order": 6, "time": "5 hours", "template": "", "required": [], @@ -202,4 +202,4 @@ "title": "Step 47" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/learn-recursion-by-building-a-decimal-to-binary-converter/meta.json b/curriculum/challenges/_meta/learn-recursion-by-building-a-decimal-to-binary-converter/meta.json index aad540de1c7..cd4c2296e23 100644 --- a/curriculum/challenges/_meta/learn-recursion-by-building-a-decimal-to-binary-converter/meta.json +++ b/curriculum/challenges/_meta/learn-recursion-by-building-a-decimal-to-binary-converter/meta.json @@ -5,7 +5,7 @@ "hasEditableBoundaries": true, "dashedName": "learn-recursion-by-building-a-decimal-to-binary-converter", "helpCategory": "JavaScript", - "order": 7, + "order": 8, "superOrder": 6, "time": "5 hours", "template": "", @@ -450,4 +450,4 @@ "title": "Step 109" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/learn-regular-expressions-by-building-a-spam-filter/meta.json b/curriculum/challenges/_meta/learn-regular-expressions-by-building-a-spam-filter/meta.json index 2012faebee3..0d2d87bf4e5 100644 --- a/curriculum/challenges/_meta/learn-regular-expressions-by-building-a-spam-filter/meta.json +++ b/curriculum/challenges/_meta/learn-regular-expressions-by-building-a-spam-filter/meta.json @@ -5,7 +5,7 @@ "hasEditableBoundaries": true, "dashedName": "learn-regular-expressions-by-building-a-spam-filter", "helpCategory": "JavaScript", - "order": 9, + "order": 10, "time": "5 hours", "template": "", "required": [], @@ -154,4 +154,4 @@ "title": "Step 35" } ] -} \ No newline at end of file +} diff --git a/curriculum/challenges/_meta/learn-the-date-object-by-building-a-date-formatter/meta.json b/curriculum/challenges/_meta/learn-the-date-object-by-building-a-date-formatter/meta.json index 4177ffbdfc4..4fd038982c6 100644 --- a/curriculum/challenges/_meta/learn-the-date-object-by-building-a-date-formatter/meta.json +++ b/curriculum/challenges/_meta/learn-the-date-object-by-building-a-date-formatter/meta.json @@ -4,7 +4,7 @@ "usesMultifileEditor": true, "hasEditableBoundaries": true, "dashedName": "learn-the-date-object-by-building-a-date-formatter", - "order": 3, + "order": 4, "time": "5 hours", "template": "", "required": [], @@ -130,4 +130,4 @@ } ], "helpCategory": "JavaScript" -} \ No newline at end of file +} diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ee6e3a242da6bd579de69.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ee6e3a242da6bd579de69.md new file mode 100644 index 00000000000..059053da933 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ee6e3a242da6bd579de69.md @@ -0,0 +1,60 @@ +--- +id: 660ee6e3a242da6bd579de69 +title: Step 1 +challengeType: 0 +dashedName: step-1 +--- + +# --description-- + +JavaScript is the programming language that powers the web. Unlike the HTML and CSS you have learned previously, JavaScript is most commonly used to write logic instead of markup. + +One of the most important concepts in programming is variables. A variable points to a specific memory address that stores a value. Variables are given a name which can be used throughout your code to access that value. + +Declaring a variable means giving it a name. In JavaScript, this is often done with the `let` keyword. For example, here is how you would declare a `hello` variable: + +```js +let hello; +``` + +Variable naming follows specific rules: names can include letters, numbers, dollar signs, and underscores, but cannot contain spaces and must not begin with a number. + +Declare a `character` variable in your code. + +_Note_: It is common practice to end statements in JavaScript with a semicolon. `;` + +# --hints-- + +You should use `let` in your code. + +```js +assert.match(code, /let/); +``` + +You should use `character` in your code. + +```js +assert.match(code, /character/); +``` + +You should use `let` to declare a `character` variable. + +```js +assert.match(code, /let\s+character/); +``` + +Your declaration should end with a semi-colon. + +```js +assert.match(code, /let\s+character;/); +``` + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660eebd83100d37862268781.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660eebd83100d37862268781.md new file mode 100644 index 00000000000..8f1ee952a16 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660eebd83100d37862268781.md @@ -0,0 +1,54 @@ +--- +id: 660eebd83100d37862268781 +title: Step 2 +challengeType: 0 +dashedName: step-2 +--- + +# --description-- + +Your `character` variable currently does not have a value. You can assign a value using the assignment operator `=`. For example: + +```js +let hello = "Hello"; +``` + +Assigning a value to a variable at the moment of its declaration is known as initialization. + +Initialize your `character` variable by assigning it the value `"Hello"` during its declaration. + +# --hints-- + +You should use the assignment operator `=`. + +```js +assert.match(code, /let\s+character\s*=/); +``` + +You should use the string `"Hello"`. + +```js +assert.match(code, /('|")Hello\1/); +``` + +You should use double quotes for your `"Hello"` string. + +```js +assert.match(code, /"Hello"/); +``` + +You should assign `"Hello"` to your `character` variable. + +```js +assert.equal(character, "Hello"); +``` + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +let character; +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef0f7c4b8e68ccd1f0786.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef0f7c4b8e68ccd1f0786.md new file mode 100644 index 00000000000..8e0785f6c2a --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef0f7c4b8e68ccd1f0786.md @@ -0,0 +1,57 @@ +--- +id: 660ef0f7c4b8e68ccd1f0786 +title: Step 3 +challengeType: 0 +dashedName: step-3 +--- + +# --description-- + +JavaScript has seven primitive data types, with `String` being one of them. In JavaScript, a string represents a sequence of characters and can be enclosed in either single (`'`) or double (`"`) quotes. + +Note that strings are immutable, which means once they are created, they cannot be changed. + +Change your `"Hello"` string to use single quotes. + +# --hints-- + +You should not have double quotes in your code. + +```js +assert.notMatch(code, /"/); +``` + +You should use single quotes for your `"Hello"` string. + +```js +assert.match(code, /'Hello'/); +``` + +You should still use `let` in your code. + +```js +assert.match(code, /let/); +``` + +You should still declare a `character` variable. + +```js +assert.match(code, /let\s+character/); +``` + +Your `character` variable should still have the string `"Hello"` for its value. + +```js +assert.equal(character, "Hello"); +``` + + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +let character = "Hello"; +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef19b95d3308e7dd31bb6.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef19b95d3308e7dd31bb6.md new file mode 100644 index 00000000000..d00ee2d3841 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef19b95d3308e7dd31bb6.md @@ -0,0 +1,57 @@ +--- +id: 660ef19b95d3308e7dd31bb6 +title: Step 4 +challengeType: 0 +dashedName: step-4 +--- + +# --description-- + +The console allows you to print and view JavaScript output. You can send information to the console using `console.log()`. For example, this code will print `"Naomi"` to the console: + +```js +let developer = "Naomi"; +console.log(developer); +``` + +The code above accesses the `developer` variable with its name in the `console.log()`. Note that the value between the parentheses is the value that will be printed. + +Print the value of the `character` variable to the console. Then, click the "Console" button to view the JavaScript console. + +# --hints-- + +You should access the `console` in your code. + +```js +assert.match(code, /console/); +``` + +You should access the `log` property of the `console`. + +```js +assert.match(code, /console\.log/); +``` + +You should use parentheses to call the `.log()` method. + +```js +assert.match(code, /console\.log\(/); +``` + +You should print the `character` variable to the console. + +```js +assert.match(code, /console\.log\(\s*character\s*\)/); +``` + + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +let character = 'Hello'; + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef31a5be625914a0102cd.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef31a5be625914a0102cd.md new file mode 100644 index 00000000000..f4683f8da46 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef31a5be625914a0102cd.md @@ -0,0 +1,64 @@ +--- +id: 660ef31a5be625914a0102cd +title: Step 5 +challengeType: 0 +dashedName: step-5 +--- + +# --description-- + +When a variable is declared with the `let` keyword, you can reassign (or change the value of) that variable later on. In this example, the value of `programmer` is changed from `"Naomi"` to `"CamperChan"`. + +```js +let programmer = "Naomi"; +programmer = "CamperChan"; +``` + +Note that when reassigning a variable that has already been declared, you do **not** use the `let` keyword. + +After your `console.log`, assign the value `"World"` to your `character` variable. + +# --hints-- + +You should use `character` twice in your code. + +```js +assert.lengthOf(code.match(/character/g), 3); +``` + +You should use the assignment operator to reassign `character`. + +```js +assert.lengthOf(code.match(/character\s*\=/g), 2); +``` + +You should use the string `"World"` in your code. + +```js +assert.match(code, /("|')World\1/); +``` + +Your `character` variable should have the value `"World"`. + +```js +assert.equal(character, "World"); +``` + +Your reassignment should not use `let`. + +```js +assert.isBelow(code.match(/let/g).length, 2); +``` + + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +let character = 'Hello'; +console.log(character); + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef5105b8ba095307a0e50.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef5105b8ba095307a0e50.md new file mode 100644 index 00000000000..2a60128389d --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef5105b8ba095307a0e50.md @@ -0,0 +1,44 @@ +--- +id: 660ef5105b8ba095307a0e50 +title: Step 6 +challengeType: 0 +dashedName: step-6 +--- + +# --description-- + +Now log your `character` variable to the console again. You should see the string `"Hello"`, then the string `"World"`, in the console. + +# --hints-- + +You should use `console.log` a second time. + +```js +assert.lengthOf(code.match(/console\.log/g), 2); +``` + +You should log `character` to the console a second time. + +```js +assert.lengthOf(code.match(/console\.log\(\s*character\s*\)/g), 2); +``` + + +Your new `console.log()` should come after your reassignment. + +```js +const reassign = code.split(/\n+/).findIndex(l => l.match(/character\s+=\s+("|')World\1/)); +``` + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +let character = 'Hello'; +console.log(character); +character = "World"; + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef55dd468079679ee0092.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef55dd468079679ee0092.md new file mode 100644 index 00000000000..d0cf996c378 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef55dd468079679ee0092.md @@ -0,0 +1,53 @@ +--- +id: 660ef55dd468079679ee0092 +title: Step 11 +challengeType: 0 +dashedName: step-11 +--- + +# --description-- + +You are now ready to declare your next variable. Remove both `console.log` statements, and the `character` reassignment. + +Also remove your `secondCharacter` variable, but leave the `character` initialization unchanged. + +# --hints-- + +You should not have any `console.log()` statements in your code. + +```js +assert.notMatch(code, /console/); +``` + +You should not reassign the value of `character`. + +```js +assert.isAtMost(code.match(/character/).length, 1); +``` + +Your `character` variable should have the value `"Hello"`. + +```js +assert.equal(character, "Hello"); +``` + +You should not have a `secondCharacter` variable. + +```js +assert.notMatch(code, /secondCharacter/); +``` + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +let character = 'Hello'; +console.log(character); +character = "World"; +let secondCharacter; +secondCharacter = character; +console.log(secondCharacter); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef5c1904955978a986a5c.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef5c1904955978a986a5c.md new file mode 100644 index 00000000000..e45d5583fe3 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef5c1904955978a986a5c.md @@ -0,0 +1,46 @@ +--- +id: 660ef5c1904955978a986a5c +title: Step 12 +challengeType: 0 +dashedName: step-12 +--- + +# --description-- + +Use `let` to declare a `count` variable. Assign it the number `8`. When using a number value, you do not use quotes. For example: + +```js +let money = 100; +``` + +# --hints-- + +You should have a second `let` keyword in your code. + +```js +assert.lengthOf(code.match(/let/g), 2); +``` + +You should use `let` to declare a `count` variable. + +```js +assert.match(code, /let\s+count/); +``` + +You should assign the number `8` to your `count` variable. + +```js +assert.equal(count, 8); +``` + + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +let character = 'Hello'; + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef6355e8f5a9e67fe5f46.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef6355e8f5a9e67fe5f46.md new file mode 100644 index 00000000000..e10e18d4d49 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef6355e8f5a9e67fe5f46.md @@ -0,0 +1,42 @@ +--- +id: 660ef6355e8f5a9e67fe5f46 +title: Step 13 +challengeType: 0 +dashedName: step-13 +--- + +# --description-- + +With the `number` data type, you can perform mathematical operations, like addition. Try printing `count + 1` to the console. + +# --hints-- + +You should access the `console` in your code. + +```js +assert.match(code, /console/); +``` + +You should access the `.log()` of the `console`. + +```js +assert.match(code, /console\.log/); +``` + +You should log `count + 1` to the console. + +```js +assert.match(code, /console\.log\(\s*count\s*\+\s*1\s*\);?/); +``` + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +let character = 'Hello'; +let count = 8; + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef857f2806aa626d29d17.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef857f2806aa626d29d17.md new file mode 100644 index 00000000000..9b13cbd5b0f --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660ef857f2806aa626d29d17.md @@ -0,0 +1,42 @@ +--- +id: 660ef857f2806aa626d29d17 +title: Step 14 +challengeType: 0 +dashedName: step-14 +--- + +# --description-- + +You can also perform subtraction (`-`), multiplication (`*`), and division (`/`). Feel free to experiment with the operators and numbers in your `console.log`. When you are ready to move on, remove the `console.log`. + +# --hints-- + +You should not have a `console.log()` in your code. + +```js +assert.notMatch(code, /console/); +``` + +Your `character` variable should still have the value `"Hello"`. + +```js +assert.equal(character, "Hello"); +``` + +Your `count` variable should still have the value `8`. + +```js +assert.equal(count, 8); +``` + +# --seed-- + +## --seed-contents-- + +```js +let character = 'Hello'; +--fcc-editable-region-- +let count = 8; +console.log(count + 1); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f033cf051ebb50ea3bf48.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f033cf051ebb50ea3bf48.md new file mode 100644 index 00000000000..571f5ed1e68 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f033cf051ebb50ea3bf48.md @@ -0,0 +1,53 @@ +--- +id: 660f033cf051ebb50ea3bf48 +title: Step 15 +challengeType: 0 +dashedName: step-15 +--- + +# --description-- + +In programming, you will often need to work with lots of data. There are many data structures that can help you organize and manage your data. One of the most basic data structures is an array. + +An array is a non-primitive data type that can hold a series of values. Non-primitive data types differ from primitive data types in that they can hold more complex data. Primitive data types like strings and numbers can only hold one value at a time. + +Arrays are denoted using square brackets (`[]`). Here is an example of a variable with the value of an empty array: + +```js +let array = []; +``` + +Declare a `rows` variable and assign it an empty array. + +# --hints-- + +You should have a `rows` variable. + +```js +assert.match(code, /rows/); +``` + +You should use `let` to declare your `rows` variable. + +```js +assert.match(code, /let\s+rows/); +``` + +You should assign an empty array to your `rows` variable. + +```js +assert.deepEqual(rows, []); +``` + + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +let character = 'Hello'; +let count = 8; + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f039ff313dbb696b007ca.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f039ff313dbb696b007ca.md new file mode 100644 index 00000000000..5e7af7acb02 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f039ff313dbb696b007ca.md @@ -0,0 +1,48 @@ +--- +id: 660f039ff313dbb696b007ca +title: Step 16 +challengeType: 0 +dashedName: step-16 +--- + +# --description-- + +When an array holds values, or elements, those values are separated by commas. Here is an array that holds two strings: + +```js +let array = ["first", "second"]; +``` + +Change your `rows` declaration to be an array with the strings `Naomi`, `Quincy,` and `CamperChan`. The order of values in an array is important, so follow that order. Remember that strings are case-sensitive. + +# --hints-- + +The first element in your array should be the string `"Naomi"`. + +```js +assert.equal(rows[0], "Naomi"); +``` + +The second element in your array should be the string `"Quincy"`. + +```js +assert.equal(rows[1], "Quincy"); +``` + +The third element in your array should be the string `"CamperChan"`. + +```js +assert.equal(rows[2], "CamperChan"); +``` + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +let character = 'Hello'; +let count = 8; +let rows = []; +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f061d259bbebc37461080.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f061d259bbebc37461080.md new file mode 100644 index 00000000000..37b11c5a837 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f061d259bbebc37461080.md @@ -0,0 +1,59 @@ +--- +id: 660f061d259bbebc37461080 +title: Step 17 +challengeType: 0 +dashedName: step-17 +--- + +# --description-- + +You can access the values inside an array using the index of the value. An index is a number representing the position of the value in the array, starting from `0` for the first value. + +You can access the value using bracket notation, such as `array[0]`. + +Use `console.log` and bracket notation to print the first value in your `rows` array. + +# --hints-- + +You should have a `console.log()` statement in your code. + +```js +assert.match(code, /console\.log/); +``` + +You should access your `rows` array. + +```js +assert.lengthOf(code.match(/rows/g), 2); +``` + +You should use bracket notation with your `rows` array. + +```js +assert.match(code, /rows\[/); +``` + +You should use bracket notation to access the first element of your `rows` array. + +```js +assert.match(code, /rows\[\s*0\s*\]/); +``` + +You should log the first element of your `rows` array. + +```js +assert.match(code, /console\.log\(\s*rows\[\s*0\s*]\s*\);?/); +``` + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +let character = 'Hello'; +let count = 8; +let rows = ["Naomi", "Quincy", "CamperChan"]; + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f07d231941bc11719f664.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f07d231941bc11719f664.md new file mode 100644 index 00000000000..b89c26a1771 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f07d231941bc11719f664.md @@ -0,0 +1,71 @@ +--- +id: 660f07d231941bc11719f664 +title: Step 18 +challengeType: 0 +dashedName: step-18 +--- + +# --description-- + +Arrays are special in that they are considered mutable. This means you can change the value at an index directly. + +For example, this code would assign the number `25` to the second element in the array: + +```js +let array = [1, 2, 3]; +array[1] = 25; +``` + +Update the **third** element of your `rows` array to be the number `10`. Then print the `rows` array to your console. + +# --hints-- + +You should use bracket notation on the `rows` array again. + +```js +assert.lengthOf(code.match(/rows\[/g), 2) +``` + +You should access the third element of the `rows` array. + +```js +assert.match(code, /rows\[\s*2\s*\]/); +``` + +You should use the assignment operator on the third element of the `rows` array. + +```js +assert.match(code, /rows\[\s*2\s*\]\s*=/); +``` + +You should assign the value `10` to the third element of your `rows` array. + +```js +assert.equal(rows[2], 10); +``` + +You should have a second `console.log` statement in your code. + +```js +assert.lengthOf(code.match(/console\.log/g), 2); +``` + +You should log the `rows` array. + +```js +assert.match(code, /console\.log\(\s*rows\s*\);?/); +``` + +# --seed-- + +## --seed-contents-- + +```js +let character = 'Hello'; +let count = 8; +let rows = ["Naomi", "Quincy", "CamperChan"]; +console.log(rows[0]); +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f09a2694b59c3a10ee304.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f09a2694b59c3a10ee304.md new file mode 100644 index 00000000000..b63cc0442a4 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f09a2694b59c3a10ee304.md @@ -0,0 +1,45 @@ +--- +id: 660f09a2694b59c3a10ee304 +title: Step 20 +challengeType: 0 +dashedName: step-20 +--- + +# --description-- + +For now, remove your first console log and your `rows[2]` assignment. Leave the second `rows` log statement for later. + +# --hints-- + +You should remove your `console.log(rows[0])` statement. + +```js +assert.notMatch(code, /console\.log\(\s*rows\[\s*0\s*\]\s*\)/); +``` + +You should remove your `rows[2]` reassignment. + +```js +assert.notMatch(code, /rows\[2\]/); +``` + +You should not remove your `console.log(rows)` statement. + +```js +assert.match(code, /console\.log\(\s*rows\s*\);/); +``` + +# --seed-- + +## --seed-contents-- + +```js +let character = 'Hello'; +let count = 8; +let rows = ["Naomi", "Quincy", "CamperChan"]; +--fcc-editable-region-- +console.log(rows[0]); +rows[rows.length - 1] = 10; +--fcc-editable-region-- +console.log(rows); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0a55847d6cc485f29ba5.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0a55847d6cc485f29ba5.md new file mode 100644 index 00000000000..84928db835e --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0a55847d6cc485f29ba5.md @@ -0,0 +1,52 @@ +--- +id: 660f0a55847d6cc485f29ba5 +title: Step 21 +challengeType: 0 +dashedName: step-21 +--- + +# --description-- + +A method in JavaScript is a function that's associated with certain values or objects. An example you've already encountered is the `.log()` method, which is part of the `console` object. + +Arrays have their own methods, and the first you will explore is the `.push()` method. This allows you to "push" a value to the end of an array. Here is an example to add the number `12` to the end of an array: + +```js +array.push(12); +``` + +Use `.push()` to add the string `"freeCodeCamp"` to the end of your `rows` array. Add this code before your `console.log` so you can see the change you made to your array. + +# --hints-- + +You should use `.push()` in your code. + +```js +assert.match(code, /\.push\(/); +``` + +You should use the `.push()` method of your `rows` array. + +```js +assert.match(code, /rows\.push\(/); +``` + +You should pass the string `"freeCodeCamp"` to your `.push()` method. + +```js +assert.match(code, /rows\.push\(\s*('|")freeCodeCamp\1\s*\);?/) +``` + +# --seed-- + +## --seed-contents-- + +```js +let character = 'Hello'; +let count = 8; +--fcc-editable-region-- +let rows = ["Naomi", "Quincy", "CamperChan"]; + +console.log(rows); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0c34aad72dc712b97624.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0c34aad72dc712b97624.md new file mode 100644 index 00000000000..d3781b94a7e --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0c34aad72dc712b97624.md @@ -0,0 +1,61 @@ +--- +id: 660f0c34aad72dc712b97624 +title: Step 22 +challengeType: 0 +dashedName: step-22 +--- + +# --description-- + +Another method essential for this project is the `.pop()` method. It removes the last element from an array and returns that element. + +When a method returns a value, you can think of it as giving the value back to you, making it available for use in other parts of your code. + +Declare a `popped` variable, and assign it the result of `rows.pop()`. Then, log your `popped` variable. + +# --hints-- + +You should declare a `popped` variable. + +```js +assert.match(code, /popped/); +``` + +You should use `let` to declare your `popped` variable. + +```js +assert.match(code, /let\s+popped/); +``` + +You should call the `.pop()` method. + +```js +assert.match(code, /\.pop\(\s*\)/); +``` + +You should call the `.pop()` method on your `rows` array. + +```js +assert.match(code, /rows\.pop\(\s*\)/); +``` + +You should log your `popped` variable. + +```js +assert.match(code, /console\.log\(\s*popped\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +let character = 'Hello'; +let count = 8; +--fcc-editable-region-- +let rows = ["Naomi", "Quincy", "CamperChan"]; +rows.push("freeCodeCamp"); + +console.log(rows); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0da9bf1035c9097af20a.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0da9bf1035c9097af20a.md new file mode 100644 index 00000000000..21754a11b50 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0da9bf1035c9097af20a.md @@ -0,0 +1,55 @@ +--- +id: 660f0da9bf1035c9097af20a +title: Step 23 +challengeType: 0 +dashedName: step-23 +--- + +# --description-- + +You should have seen `"freeCodeCamp"` printed to the console. This is because `.pop()` returns the value that was removed from the array - and you pushed `"freeCodeCamp"` to the end of the array earlier. + +But what does `.push()` return? Assign your existing `rows.push()` to a new `pushed` variable, and log it. + +# --hints-- + +You should declare a `pushed` variable. + +```js +assert.match(code, /pushed/); +``` + +You should use `let` to declare your `pushed` variable. + +```js +assert.match(code, /let\s+pushed/); +``` + +You should assign `rows.push("freeCodeCamp")` to your `pushed` variable. + +```js +assert.equal(pushed, 4); +``` + +You should log your `pushed` variable. + +```js +assert.match(code, /console\.log\(\s*pushed\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +let character = 'Hello'; +let count = 8; +let rows = ["Naomi", "Quincy", "CamperChan"]; +--fcc-editable-region-- +rows.push("freeCodeCamp"); + +--fcc-editable-region-- +let popped = rows.pop(); +console.log(popped); +console.log(rows); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0ee51d7460ce88cd248d.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0ee51d7460ce88cd248d.md new file mode 100644 index 00000000000..2e90cbb28d8 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0ee51d7460ce88cd248d.md @@ -0,0 +1,61 @@ +--- +id: 660f0ee51d7460ce88cd248d +title: Step 24 +challengeType: 0 +dashedName: step-24 +--- + +# --description-- + +Were you expecting to see `4` in the console? `.push()` returns the new length of the array, after adding the value you give it. + +It is important to be aware of what values a method returns. Take some time to experiment with `.push()` and `.pop()`. When you are ready, remove all of your `.push()` and `.pop()` calls, and your `console.log` statements. + +# --hints-- + +You should not have a `.push()` call. + +```js +assert.notMatch(code, /\.push\(/); +``` + +You should not have a `.pop()` call. + +```js +assert.notMatch(code, /.pull\(/); +``` + +You should not have any log statements. + +```js +assert.notMatch(code, /console\.log/); +``` + +You should not have a `popped` variable. + +```js +assert.notMatch(code, /popped/); +``` + +You should not have a `pushed` variable. + +```js +assert.notMatch(code, /pushed/); +``` + +# --seed-- + +## --seed-contents-- + +```js +let character = 'Hello'; +let count = 8; +let rows = ["Naomi", "Quincy", "CamperChan"]; +--fcc-editable-region-- +let pushed = rows.push("freeCodeCamp"); +console.log(pushed); +let popped = rows.pop(); +console.log(popped); +console.log(rows); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0f980e98e8cf77f1ce31.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0f980e98e8cf77f1ce31.md new file mode 100644 index 00000000000..872acf29443 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f0f980e98e8cf77f1ce31.md @@ -0,0 +1,38 @@ +--- +id: 660f0f980e98e8cf77f1ce31 +title: Step 25 +challengeType: 0 +dashedName: step-25 +--- + +# --description-- + +Change your `rows` declaration to be assigned an empty array again. + +Also, change your `'Hello'` string to use double quotes again. Generally, it does not matter which of the two you prefer, but you will want to be consistent in that choice throughout your project. + +# --hints-- + +Your `rows` array should be empty. + +```js +assert.empty(rows); +``` + +Your `"Hello"` string should use double quotes. + +```js +assert.match(code, /"Hello"/); +``` + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +let character = 'Hello'; +let count = 8; +let rows = ["Naomi", "Quincy", "CamperChan"]; +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f165270622fd4ec0da3f7.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f165270622fd4ec0da3f7.md new file mode 100644 index 00000000000..abcd6a74295 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f165270622fd4ec0da3f7.md @@ -0,0 +1,65 @@ +--- +id: 660f165270622fd4ec0da3f7 +title: Step 26 +challengeType: 0 +dashedName: step-26 +--- + +# --description-- + +The `let` keyword allows a variable to be reassigned. This means you could change `character` later to be a completely different value. + +For this project, you will not want to change these variable values. So instead, you should use `const` to declare them. `const` variables are special. + +First, a `const` variable cannot be reassigned like a `let` variable. This code would throw an error: + +```js +const firstName = "Naomi"; +firstName = "Jessica"; +``` + +A `const` variable also cannot be uninitialized. This code would throw an error: + +```js +const firstName; +``` + +Replace your `let` keywords with `const`. + +# --hints-- + +You should use `const` to declare your `character` variable. + +```js +assert.match(code, /const\s+character/); +``` + +You should use `const` to declare your `count` variable. + +```js +assert.match(code, /const\s+count/); +``` + +You should use `const` to declare your `rows` variable. + +```js +assert.match(code, /const\s+rows/); +``` + +You should not use `let` in your code. + +```js +assert.notMatch(code, /let/); +``` + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +let character = "Hello"; +let count = 8; +let rows = []; +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f17294346b7d69e79db3d.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f17294346b7d69e79db3d.md new file mode 100644 index 00000000000..f2d131505ba --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f17294346b7d69e79db3d.md @@ -0,0 +1,32 @@ +--- +id: 660f17294346b7d69e79db3d +title: Step 27 +challengeType: 0 +dashedName: step-27 +--- + +# --description-- + +You are now ready to start building your pyramid generator. Your `character` variable will serve as the building block for the pyramid. + +`"Hello"` might not work very well for that. Change the value of `character` to be the hash character `"#"`. + +# --hints-- + +Your `character` variable should be a hash symbol. + +```js +assert.equal(character, "#"); +``` + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +const character = "Hello"; +const count = 8; +const rows = []; +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f17d4e9f227d86e834abd.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f17d4e9f227d86e834abd.md new file mode 100644 index 00000000000..2083bdee843 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f17d4e9f227d86e834abd.md @@ -0,0 +1,67 @@ +--- +id: 660f17d4e9f227d86e834abd +title: Step 28 +challengeType: 0 +dashedName: step-28 +--- + +# --description-- + +To generate a pyramid, you will need to create multiple rows. When you have to perform a task repeatedly until a condition is met, you will use a loop. There are many ways to write a loop. + +You are going to start with a basic `for` loop. `for` loops use the following syntax: + +```js +for (iterator; condition; iteration) { + logic; +} +``` + +In the upcoming steps, you'll explore each component of a loop in detail. For now, construct a `for` loop that includes the terms `"iterator"`, `"condition"`, and `"iteration"` for the three components. Keep the loop body, the section within the curly braces `{}`, empty. + + +# --hints-- + +You should have a `for` loop. + +```js +assert.match(code, /for/); +``` + +The first component of your `for` loop should be the string `"iterator"`. + +```js +assert.match(code, /for\s*\(\s*('|")iterator\1/); +``` + +The second component of your `for` loop should be the string `"condition"`. + +```js +assert.match(code, /for\s*\(\s*('|")iterator\1\s*;\s*('|")condition\2/); +``` + +The third component of your `for` loop should be the string `"iteration"`. + +```js +assert.match(code, /for\s*\(\s*('|")iterator\1\s*;\s*('|")condition\2\s*;\s*('|")iteration\3\s*\)/); +``` + +The body of your `for` loop should be empty. + +```js +assert.match(code, /for\s*\(\s*('|")iterator\1\s*;\s*('|")condition\2\s*;\s*('|")iteration\3\s*\)\s*\{\s*\}/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f18f059fe0fda192ce394.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f18f059fe0fda192ce394.md new file mode 100644 index 00000000000..644584ac44c --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f18f059fe0fda192ce394.md @@ -0,0 +1,56 @@ +--- +id: 660f18f059fe0fda192ce394 +title: Step 29 +challengeType: 0 +dashedName: step-29 +--- + +# --description-- + +Your loop now needs a proper iterator. The iterator is a variable you can declare specifically in your `for` loop to control how the loop iterates or goes through your logic. + +It is a common convention to use `i` as your iterator variable in a loop. A `for` loop allows you to declare this in the parentheses `()`. For example, here is a `for` loop that declares an `index` variable and assigns it the value `100`. + +```js +for (let index = 100; "second"; "third") { + +} +``` + +Replace the string `"iterator"` with a `let` declaration for the variable `i`. Assign it the value `0` to start. This will give the `i` variable the value `0` the **first time** your loop runs. + +# --hints-- + +You should use `let` to declare an `i` variable. + +```js +assert.match(code, /let\s+i/); +``` + +You should assign `0` to your `i` variable. + +```js +assert.match(code, /let\s+i\s*=\s*0/); +``` + +Your `for` loop should start an `i` iterator at `0`. + +```js +assert.match(code, /for\s*\(\s*let\s+i\s*=\s*0/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +for ("iterator"; "condition"; "iteration") { + +} +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1a00ac619ddc1e259a66.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1a00ac619ddc1e259a66.md new file mode 100644 index 00000000000..505641e0ec4 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1a00ac619ddc1e259a66.md @@ -0,0 +1,52 @@ +--- +id: 660f1a00ac619ddc1e259a66 +title: Step 30 +challengeType: 0 +dashedName: step-30 +--- + +# --description-- + +The condition of a `for` loop tells the loop how many times it should iterate. When the `condition` becomes true, the loop will stop. + +In JavaScript, a Boolean value can be either `true` or `false`. These are not strings - you will learn more about the difference later on. + +For now, you will use the less than operator (`<`). This allows you to check if the value on the left is less than the value on the right. For example, `count < 3` would evaluate to `true` if `count` is `2`, and `false` if `count` is `4`. + +Replace your `"condition"` string with a condition to check if `i` is less than `count`. + +# --hints-- + +You should use the less than operator. + +```js +assert.match(code, /iteration statement will tell your loop what to do with the iterator after each run. + +When you reassign a variable, you can use the variable to reference the previous value before the reassignment. This allows you to do things like add three to an existing number. For example, `bees = bees + 3;` would increase the value of `bees` by three. + +Use that syntax to replace your `"iteration"` string with a reassignment statement that increases `i` by one. + +# --hints-- + +You should add one to your `i` variable. + +```js +assert.match(code, /i\s*\+\s*1/); +``` + +You should assign `i + 1` back to your `i` variable. + +```js +assert.match(code, /i\s*=\s*i\s*\+\s*1/); +``` + +Your `for` loop should increase `i` by `1` on each iteration. + +```js +assert.match(code, /for\s*\(\s*let\s+i\s*=\s*0;\s*i\s*<\s*count;\s*i\s*=\s*i\s*\+\s*1\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +for (let i = 0; i < count; "iteration") { + +} +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1bf673487ae0bb25b900.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1bf673487ae0bb25b900.md new file mode 100644 index 00000000000..dae3a444593 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1bf673487ae0bb25b900.md @@ -0,0 +1,46 @@ +--- +id: 660f1bf673487ae0bb25b900 +title: Step 32 +challengeType: 0 +dashedName: step-32 +--- + +# --description-- + +Your loop should now run eight times. Inside the body of the loop, print the value of the `i` iterator and see what happens. + +# --hints-- + +You should use `console.log()`. + +```js +assert.match(code, /console\.log/) +``` + +You should log the value of `i`. + +```js +assert.match(code, /console\.log\(\s*i\s*\)/); +``` + +You should log the value of `i` in your `for` loop. + +```js +assert.match(code, /for\s*\(\s*let\s+i\s*=\s*0;\s*i\s*<\s*count;\s*i\s*=\s*i\s*\+\s*1\s*\)\s*\{\s*console\.log\(\s*i\s*\);?\s*\}/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +for (let i = 0; i < count; i = i + 1) { + +} +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1cedf3676fe26122ebf6.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1cedf3676fe26122ebf6.md new file mode 100644 index 00000000000..b9a258c33c9 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1cedf3676fe26122ebf6.md @@ -0,0 +1,54 @@ +--- +id: 660f1cedf3676fe26122ebf6 +title: Step 33 +challengeType: 0 +dashedName: step-33 +--- + +# --description-- + +You should see the numbers zero through seven printed in your console, one per line. This will serve as the foundation for generating your pyramid. + +Replace your log statement with a statement to push `i` to your `rows` array. + +# --hints-- + +You should not have a `console.log` call. + +```js +assert.notMatch(code, /console/); +``` + +You should call `.push()` on your `rows` array. + +```js +assert.match(code, /rows\.push\(/); +``` + +You should push `i` to your `rows` array. + +```js +assert.match(code, /rows\.push\(\s*i\s*\)/); +``` + +Your `.push()` should happen in your `for` loop. + +```js +assert.match(code, /for\s*\(\s*let\s+i\s*=\s*0;\s*i\s*<\s*count;\s*i\s*=\s*i\s*\+\s*1\s*\)\s*\{\s*rows\.push\(\s*i\s*\);?\s*\}/) +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +for (let i = 0; i < count; i = i + 1) { + console.log(i); +} +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1e3f047bf4e403268713.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1e3f047bf4e403268713.md new file mode 100644 index 00000000000..659ab98baa3 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f1e3f047bf4e403268713.md @@ -0,0 +1,50 @@ +--- +id: 660f1e3f047bf4e403268713 +title: Step 34 +challengeType: 0 +dashedName: step-34 +--- + +# --description-- + +Unfortunately, now you cannot see what your loop is doing. + +Use `let` to declare a `result` variable, and assign it an empty string. An empty string is represented by quotation marks with nothing between them, such as `""`. + +# --hints-- + +You should declare a `result` variable. + +```js +assert.match(code, /result/); +``` + +You should use `let` to declare your `result` variable. + +```js +assert.match(code, /let\s*result/); +``` + +Your `result` variable should be an empty string. + +```js +assert.equal(result, ""); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +for (let i = 0; i < count; i = i + 1) { + rows.push(i); +} + +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f20473aef47e9b8c9afc6.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f20473aef47e9b8c9afc6.md new file mode 100644 index 00000000000..00b708765d5 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f20473aef47e9b8c9afc6.md @@ -0,0 +1,44 @@ +--- +id: 660f20473aef47e9b8c9afc6 +title: Step 35 +challengeType: 0 +dashedName: step-35 +--- + +# --description-- + +Add a log statement to print the value of `result`. Depending on which console you use, you may not see anything printed. + +# --hints-- + +You should add a `console.log` call. + +```js +assert.match(code, /console\.log\(/); +``` + +You should log your `result` variable. + +```js +assert.match(code, /console\.log\(\s*result\s*\);?/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +for (let i = 0; i < count; i = i + 1) { + rows.push(i); +} + +let result = "" + +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f207334fabaeac3269c38.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f207334fabaeac3269c38.md new file mode 100644 index 00000000000..77dfe2d9c0b --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f207334fabaeac3269c38.md @@ -0,0 +1,82 @@ +--- +id: 660f207334fabaeac3269c38 +title: Step 36 +challengeType: 0 +dashedName: step-36 +--- + +# --description-- + +To manipulate the `result` string, you will use a different type of loop. Specifically, a `for...of` loop, which iterates over each item in an iterable object and temporarily assigns it to a variable. + +The syntax for a `for...of` loop looks like: + +```js +for (const value of iterable) { + +} +``` + +Note that you can use `const` because the variable only exists for a single iteration, not during the entire loop. + +Create a `for...of` loop to iterate through your `rows` array, assigning each value to a `row` variable. + +# --hints-- + +You should use another `for` keyword. + +```js +assert.lengthOf(code.match(/for/g), 2); +``` + +You should declare a `row` variable. + +```js +assert.match(code, /\s+row\s+/); +``` + +You should use `const` to declare your `row` variable. + +```js +assert.match(code, /const\s+row\s+/); +``` + +Your `for...of` loop should declare your `row` variable. + +```js +assert.match(code, /for\s*\(\s*const\s+row\s+/); +``` + +Your `row` variable should be extracted from `rows` using the `of` keyword. + +```js +assert.match(code, /for\s*\(\s*const\s+row\s+of\s+rows\s*\)/); +``` + +Your `for...of` loop body should be empty. + +```js +assert.match(code, /for\s*\(\s*const\s+row\s+of\s+rows\s*\)\s*\{\s*\}/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +for (let i = 0; i < count; i = i + 1) { + rows.push(i); +} + +let result = "" + +--fcc-editable-region-- + +--fcc-editable-region-- + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f229d2dbe09ef2954a4a1.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f229d2dbe09ef2954a4a1.md new file mode 100644 index 00000000000..592fc86ccbf --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f229d2dbe09ef2954a4a1.md @@ -0,0 +1,58 @@ +--- +id: 660f229d2dbe09ef2954a4a1 +title: Step 37 +challengeType: 0 +dashedName: step-37 +--- + +# --description-- + +Remember in your previous loop that you used the addition operator `+` to increase the value of `i` by `1`. + +You can do a similar thing with a string value, by appending a new string to an existing string. For example, `hello = hello + " World";` would add the string `" World"` to the existing string stored in the `hello` variable. This is called concatenation. + +In your `for...of` loop, use the addition operator to concatenate the `row` value to the `result` value. + +# --hints-- + +You should use the concatenation operator on your `result` variable. + +```js +assert.match(code, /result\s*\+/); +``` + +You should concatenate `row` to your `result` variable. + +```js +assert.match(code, /result\s*\+\s*row/); +``` + +You should assign the result of your concatenation back to the `result` variable. + +```js +assert.match(code, /result\s*=\s*result\s*\+\s*row;?/) +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +for (let i = 0; i < count; i = i + 1) { + rows.push(i); +} + +let result = "" + +--fcc-editable-region-- +for (const row of rows) { + +} +--fcc-editable-region-- + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f23b53db70af0f2620e78.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f23b53db70af0f2620e78.md new file mode 100644 index 00000000000..6437723c02e --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f23b53db70af0f2620e78.md @@ -0,0 +1,68 @@ +--- +id: 660f23b53db70af0f2620e78 +title: Step 38 +challengeType: 0 +dashedName: step-38 +--- + +# --description-- + +Now all of your numbers are appearing on the same line. This will not work for creating a pyramid. + +You will need to add a new line to each row. However, pressing the return key to insert a line break between quotes in JavaScript will result in a parsing error. Instead, you need to use the special escape sequence `\n`, which is interpreted as a new line when the string is logged. For example: + +```js +lineOne = lineOne + "\n" + lineTwo; +``` + +Use a second addition operator to concatenate a new line between the existing `result` value and the added `row` value. + +# --hints-- + +You should use the `\n` escape sequence. Remember that it needs to be a string, so it is wrapped in quotes. + +```js +assert.match(code, /('|")\\n\1/); +``` + +You should concatenate the `\n` escape sequence to your `result` variable. + +```js +assert.match(code, /result\s*\+\s*('|")\\n\1/); +``` + +You should concatenate your `row` variable to your `\n` escape sequence. + +```js +assert.match(code, /result\s*\+\s*('|")\\n\1\s*\+\s*row/); +``` + +You should assign the entire concatenation back to your `result` variable. Don't forget your semi-colon. + +```js +assert.match(code, /result\s*=\s*result\s*\+\s*('|")\\n\1\s*\+\s*row;/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +for (let i = 0; i < count; i = i + 1) { + rows.push(i); +} + +let result = "" + +--fcc-editable-region-- +for (const row of rows) { + result = result + row; +} +--fcc-editable-region-- + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f255022991ef34ed0ee88.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f255022991ef34ed0ee88.md new file mode 100644 index 00000000000..aaa93d28e66 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f255022991ef34ed0ee88.md @@ -0,0 +1,50 @@ +--- +id: 660f255022991ef34ed0ee88 +title: Step 39 +challengeType: 0 +dashedName: step-39 +--- + +# --description-- + +Printing numbers won't result in a visually appealing pyramid. Now that you're outputting the formatted content of your `rows` array, it's time to update your original loop. + +Instead of pushing `i` to the array, push the value of your `character` variable. + +# --hints-- + +You should no longer push your `i` variable. + +```js +assert.notMatch(code, /rows\.push\(\s*i\s*\)/); +``` + +You should push your `character` variable. + +```js +assert.match(code, /rows\.push\(\s*character\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +for (let i = 0; i < count; i = i + 1) { + rows.push(i); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f280dda5040f707c76b4a.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f280dda5040f707c76b4a.md new file mode 100644 index 00000000000..a635acb8bf2 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f280dda5040f707c76b4a.md @@ -0,0 +1,63 @@ +--- +id: 660f280dda5040f707c76b4a +title: Step 40 +challengeType: 0 +dashedName: step-40 +--- + +# --description-- + +Now you have a series of `#` characters, but the pyramid shape is still missing. Fortunately, the `i` variable represents the current "row" number in your loop, enabling you to use it for crafting a pyramid-like structure. + +To achieve this, you will use the `.repeat()` method available to strings. This method accepts a number as an argument, specifying the number of times to repeat the target string. For example, using `.repeat()` to generate the string `"Code! Code! Code!"`: + +```js +const activity = "Code! "; +activity.repeat(3); +``` + +Use the `.repeat()` method on your `character`, and give it `i` for the number. + +# --hints-- + +You should use the `.repeat()` method. + +```js +assert.match(code, /\.repeat\(/); +``` + +You should use the `.repeat()` method on your `character` variable. + +```js +assert.match(code, /character\.repeat\(/); +``` + +You should pass `i` to your `.repeat()` method. + +```js +assert.match(code, /character\.repeat\(\s*i\s*\)/) +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +for (let i = 0; i < count; i = i + 1) { + rows.push(character); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f2a70ad6225fa503e71c3.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f2a70ad6225fa503e71c3.md new file mode 100644 index 00000000000..a53b7b420b4 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f2a70ad6225fa503e71c3.md @@ -0,0 +1,46 @@ +--- +id: 660f2a70ad6225fa503e71c3 +title: Step 41 +challengeType: 0 +dashedName: step-41 +--- + +# --description-- + +You're getting closer! At this point, you're encountering what's known as an off-by-one error, a frequent problem in zero-based indexing languages like JavaScript. + +The first index of your `rows` array is `0`, which is why you start your `for` loop with `i = 0`. But repeating a string zero times results in nothing to print. + +To fix this, add `1` to the value of `i` in your `.repeat()` call. Do not assign it back to `i` like you did in your loop conditions. + +# --hints-- + +You should add `1` to `i` in your `.repeat()` method. + +```js +assert.match(code, /character\.repeat\(\s*i\s*\+\s*1\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i)) +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f2b6fd54ac1fc142804dd.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f2b6fd54ac1fc142804dd.md new file mode 100644 index 00000000000..748317bdb9e --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f2b6fd54ac1fc142804dd.md @@ -0,0 +1,75 @@ +--- +id: 660f2b6fd54ac1fc142804dd +title: Step 42 +challengeType: 0 +dashedName: step-42 +--- + +# --description-- + +The logic for formatting this pyramid is likely going to get complicated, which means it's a great time to extract that code into a function. + +A function is a block of code that can be reused throughout your application. Functions are declared with the following syntax: + +```js +function name(parameter) { + +} +``` + +The `function` keyword tells JavaScript that the `name` variable is going to be a function. `parameter` is a variable that represents a value that is passed into the function when it is used. A function may have as many, or as few, parameters as you'd like. Like a `for` loop, the space between the curly braces is the function body. + +Declare a `padRow` function. Do not create any parameter variables yet. The function body should be empty. Remember that you need to use camel case for your naming convention. + +# --hints-- + +You should use the `function` keyword. + +```js +assert.match(code, /function/); +``` + +You should declare a `padRow` function. + +```js +assert.isFunction(padRow); +``` + +Your `padRow()` function should not have any parameters. + +```js +assert.match(code, /padRow\s*\(\s*\)/); +``` + +Your `padRow()` function should have an empty body. + +```js +assert.match(code, /padRow\s*\(\s*\)\s*\{\s*\}/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- + +--fcc-editable-region-- + + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f2eccfe3f820304af1b39.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f2eccfe3f820304af1b39.md new file mode 100644 index 00000000000..d255c09a39c --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f2eccfe3f820304af1b39.md @@ -0,0 +1,67 @@ +--- +id: 660f2eccfe3f820304af1b39 +title: Step 57 +challengeType: 0 +dashedName: step-57 +--- + +# --description-- + +In order to know how to format a row, your `padRow` function will need to know which row number you are on, and how many rows in total are being generated. + +The best way to do this is by creating function parameters for them. Give your `padRow` function a `rowNumber` and `rowCount` parameter. Multiple parameters are separated by a comma: + +```js +function name(first, second) { + +} +``` + +# --hints-- + +Your `padRow` function should have a `rowNumber` parameter. + +```js +assert.match(code, /function\s+padRow\s*\(\s*rowNumber/); +``` + +You should add a comma after your `rowNumber` parameter. + +```js +assert.match(code, /function\s+padRow\s*\(\s*rowNumber\s*,\s*/); +``` + +Your `padRow` function should have a `rowCount` parameter. + +```js +assert.match(code, /function\s+padRow\s*\(\s*rowNumber\s*,\s*rowCount\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow() { + +} +--fcc-editable-region-- + + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f2fbd45b520046cac68e8.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f2fbd45b520046cac68e8.md new file mode 100644 index 00000000000..871145578bc --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f2fbd45b520046cac68e8.md @@ -0,0 +1,81 @@ +--- +id: 660f2fbd45b520046cac68e8 +title: Step 58 +challengeType: 0 +dashedName: step-58 +--- + +# --description-- + +Remember in an earlier step, you learned about return values. A function can return a value for your application to consume separately. + +In a function, the `return` keyword is used to specify a return value. For example, this function would return the value given to the first parameter: + +```js +function name(parameter) { + return parameter; +} +``` + +Use the `return` keyword to return the value of the `character` variable, repeated `rowNumber` times. + +# --hints-- + +You should use the `.repeat()` method. + +```js +assert.lengthOf(code.match(/\.repeat\(/g), 2); +``` + +You should use the `.repeat()` method on your `character` variable. + +```js +assert.lengthOf(code.match(/character\.repeat\(/g), 2); +``` + +You should pass `rowNumber` to your `.repeat()` call. + +```js +assert.match(code, /character\.repeat\(\s*rowNumber\s*\)/); +``` + +You should use the `return` keyword. + +```js +assert.match(code, /return/); +``` + +You should return the result of your `.repeat()` call. + +```js +assert.equal(padRow(3), "###"); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow(rowNumber, rowCount) { + +} +--fcc-editable-region-- + + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f34626216270c682e2f7b.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f34626216270c682e2f7b.md new file mode 100644 index 00000000000..09386b488bb --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f34626216270c682e2f7b.md @@ -0,0 +1,67 @@ +--- +id: 660f34626216270c682e2f7b +title: Step 59 +challengeType: 0 +dashedName: step-59 +--- + +# --description-- + +A function call allows you to actually use a function. You may not have been aware of it, but the methods like `.push()` that you have been using have been function calls. + +A function is called by referencing the function's name, and adding `()`. Here's how to call a `test` function: + +```js +test(); +``` + +Replace the `character.repeat(i + 1)` in your `.push()` call with a function call for your `padRow` function. + +# --hints-- + +You should not use `i + 1` in your `push` call. + +```js +assert.notMatch(code, /repeat\(\s*i\s*\+\s*1\s*\)/); +``` + +You should not use `character.repeat` in your `.push()` call. + +```js +assert.notMatch(code, /push\(\s*character/); +``` + +You should call `padRow` in your `.push()` call. + +```js +assert.match(code, /push\(\s*padRow\(\s*\)\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return character.repeat(rowNumber); +} + + +--fcc-editable-region-- +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f34e99571070d56d2f231.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f34e99571070d56d2f231.md new file mode 100644 index 00000000000..88162bcc52e --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f34e99571070d56d2f231.md @@ -0,0 +1,67 @@ +--- +id: 660f34e99571070d56d2f231 +title: Step 60 +challengeType: 0 +dashedName: step-60 +--- + +# --description-- + +Your `padRow` function has two parameters which you defined. Values are provided to those parameters when a function is called. + +The values you provide to a function call are referred to as arguments, and you pass arguments to a function call. Here's a function call with `"Hello"` passed as an argument: + +```js +test("Hello"); +``` + +Pass `i + 1` and `count` as the arguments to your `padRow` call. Like parameters, arguments are separated by a comma. + +# --hints-- + +You should pass `i + 1` to your `padRow()` call. + +```js +assert.match(code, /push\(\s*padRow\(\s*i\s*\+\s*1/); +``` + +You should have a comma after your `i + 1` argument. + +```js +assert.match(code, /push\(\s*padRow\(\s*i\s*\+\s*1\s*,\s*/); +``` + +You should pass `count` as your second argument. + +```js +assert.match(code, /push\(\s*padRow\(\s*i\s*\+\s*1\s*,\s*count\s*\)\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return character.repeat(rowNumber); +} + + +--fcc-editable-region-- +for (let i = 0; i < count; i = i + 1) { + rows.push(padRow()) +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f359af3e32e0f1a6880b7.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f359af3e32e0f1a6880b7.md new file mode 100644 index 00000000000..8cc35656228 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f359af3e32e0f1a6880b7.md @@ -0,0 +1,60 @@ +--- +id: 660f359af3e32e0f1a6880b7 +title: Step 61 +challengeType: 0 +dashedName: step-61 +--- + +# --description-- + +You should now see the same bunch of characters in your console. Your `padRow` function is doing the exact same thing you were doing earlier, but now it's in a reusable section of its own. + +Use the addition operator to concatenate a blank space `" "` to the beginning and end of your repeated `character` string. + +# --hints-- + +You should concatenate an empty space to the beginning of your returned value. + +```js +assert.match(padRow(1, 1), /^\s/); +``` + +You should concatenate an empty space to the end of your returned value. + +```js +assert.match(padRow(1, 1), /\s$/); +``` + +Your `padRow()` function should return the repeated `character` series with a space before and after the series. + +```js +assert.equal(padRow(1, 1), " # "); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow(rowNumber, rowCount) { + return character.repeat(rowNumber); +} +--fcc-editable-region-- + +for (let i = 0; i < count; i = i + 1) { + rows.push(padRow(i + 1, count)); +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f374d532dc41189cc9cc2.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f374d532dc41189cc9cc2.md new file mode 100644 index 00000000000..da8790b115b --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f374d532dc41189cc9cc2.md @@ -0,0 +1,64 @@ +--- +id: 660f374d532dc41189cc9cc2 +title: Step 62 +challengeType: 0 +dashedName: step-62 +--- + +# --description-- + +Now it is time for a bit of math. Consider a three-row pyramid. If we want it centered, it would look something like: + +```md +··#·· +·###· +##### +``` + +Empty spaces have been replaced with interpuncts, or middle dots, for readability. If you extrapolate the pattern, you can see that the spaces at the beginning and end of a row follow a pattern. + +Update your blank space strings to be repeated `rowCount - rowNumber` times. + +Open up the console to see the result. + +# --hints-- + +You should call `.repeat()` on your two `" "` strings. + +```js +assert.lengthOf(code.match(/" ".repeat/g), 2); +``` + +Your `" "` strings should be repeated `rowCount - rowNumber` times. + +```js +assert.equal(padRow(1, 3), " # "); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow(rowNumber, rowCount) { + return " " + character.repeat(rowNumber) + " "; +} +--fcc-editable-region-- + +for (let i = 0; i < count; i = i + 1) { + rows.push(padRow(i + 1, count)); +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f383d4c772c12ff59904b.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f383d4c772c12ff59904b.md new file mode 100644 index 00000000000..132c4573df0 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f383d4c772c12ff59904b.md @@ -0,0 +1,63 @@ +--- +id: 660f383d4c772c12ff59904b +title: Step 63 +challengeType: 0 +dashedName: step-63 +--- + +# --description-- + +You can pass full expressions as an argument. The function will receive the result of evaluating that expression. For example, these two function calls would yield the same result: + +```js +test(2 * 3 + 1); +test(7); +``` + +Looking at the pattern again: + +```md +··#·· +·###· +##### +``` + +Update the `character` value to be repeated `2 * rowNumber - 1` times. + +Open up the console again to see the updated result. + +# --hints-- + +Your function should pass `2 * rowNumber - 1` to your `.repeat()` call. + +```js +assert.equal(padRow(4, 5), " ####### "); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(rowNumber) + " ".repeat(rowCount - rowNumber); +} +--fcc-editable-region-- + +for (let i = 0; i < count; i = i + 1) { + rows.push(padRow(i + 1, count)); +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f38c34a4de6141c0c369f.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f38c34a4de6141c0c369f.md new file mode 100644 index 00000000000..b44ad81a61b --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f38c34a4de6141c0c369f.md @@ -0,0 +1,61 @@ +--- +id: 660f38c34a4de6141c0c369f +title: Step 64 +challengeType: 0 +dashedName: step-64 +--- + +# --description-- + +Your pyramid generator now functions as expected. But this is an excellent opportunity to further explore the code you have written. + +The addition operator is not the only way to add values to a variable. The addition assignment operator can be used as shorthand to mean "take the original value of the variable, add this value, and assign the result back to the variable." For example, these two statements would yield the same result: + +```js +test = test + 1; +test += 1; +``` + +Update your iterator statement in the `for` loop to use addition assignment. + +# --hints-- + +Your `for` loop should not use `i = i + 1`; + +```js +assert.notMatch(code, /i\s*=\s*i\s*\+\s*1/); +``` + +Your `for` loop should use addition assignment with `i`. + +```js +assert.match(code, /i\s*\+=\s*1/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +--fcc-editable-region-- +for (let i = 0; i < count; i = i + 1) { +--fcc-editable-region-- + rows.push(padRow(i + 1, count)); +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3915b41a441537ec9f5e.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3915b41a441537ec9f5e.md new file mode 100644 index 00000000000..2e261c9b58d --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3915b41a441537ec9f5e.md @@ -0,0 +1,59 @@ +--- +id: 660f3915b41a441537ec9f5e +title: Step 65 +challengeType: 0 +dashedName: step-65 +--- + +# --description-- + +Because you are only increasing `i` by `1`, you can use the increment operator `++`. This operator increases the value of a variable by 1, updating the assignment for that variable. For example, `test` would become `8` here: + +```js +let test = 7; +test++; +``` + +Replace your addition assignment with the increment operator for your loop iteration. + +# --hints-- + +Your `for` loop should not use addition assignment with `i`. + +```js +assert.notMatch(code, /i\s*\+=\s*1/); +``` + +Your `for` loop should use the increment operator on `i`. + +```js +assert.match(code, /i\s*\+\+/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +--fcc-editable-region-- +for (let i = 0; i < count; i += 1) { +--fcc-editable-region-- + rows.push(padRow(i + 1, count)); +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f39b444fd6f16d1e49c1f.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f39b444fd6f16d1e49c1f.md new file mode 100644 index 00000000000..4c4914f9294 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f39b444fd6f16d1e49c1f.md @@ -0,0 +1,48 @@ +--- +id: 660f39b444fd6f16d1e49c1f +title: Step 66 +challengeType: 0 +dashedName: step-66 +--- + +# --description-- + +Rather than having to pass `i + 1` to your `padRow` call, you could instead start your loop at `1`. This would allow you to create a one-indexed loop. + +Update your iterator to start at `1` instead of `0`. + +# --hints-- + +Your `for` loop should initialise `i` at `1`. + +```js +assert.match(code, /for\s*\(\s*let\s+i\s*=\s*1/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +--fcc-editable-region-- +for (let i = 0; i < count; i++) { + rows.push(padRow(i + 1, count)); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3b664421471aa595170f.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3b664421471aa595170f.md new file mode 100644 index 00000000000..c171d4cbc58 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3b664421471aa595170f.md @@ -0,0 +1,54 @@ +--- +id: 660f3b664421471aa595170f +title: Step 67 +challengeType: 0 +dashedName: step-67 +--- + +# --description-- + +The pyramid looks a little funny now. Because you are starting the loop at `1` instead of `0`, you do not need to add one to `i` when you pass it to `padRow`. + +Update the first argument of your `padRow` call to be `i`. + +# --hints-- + +You should not pass `i + 1` to `padRow`. + +```js +assert.notMatch(code, /padRow\(\s*i\s*\+\s*1/); +``` + +You should pass `i` to `padRow`. + +```js +assert.match(code, /padRow\(\s*i\s*,/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +--fcc-editable-region-- +for (let i = 1; i < count; i++) { + rows.push(padRow(i + 1, count)); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3ba3cceef11b6ba08b59.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3ba3cceef11b6ba08b59.md new file mode 100644 index 00000000000..a41d945b1ad --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3ba3cceef11b6ba08b59.md @@ -0,0 +1,58 @@ +--- +id: 660f3ba3cceef11b6ba08b59 +title: Step 68 +challengeType: 0 +dashedName: step-68 +--- + +# --description-- + +Unfortunately, now the bottom of the pyramid has disappeared. This is because you have created another off-by-one error. + +Your original loop went for `i` values from `0` to `7`, because `count` is `8` and your condition requires `i` to be less than `count`. Your loop is now running for `i` values from `1` to `7`. + +Your loop needs to be updated to run when `i` is `8`, too. Looking at your logic, this means your loop should run when `i` is less than or equal to `count`. You can use the less than or equal to operator `<=` for this. + +Update your loop condition to run while `i` is less than or equal to `count`. + +# --hints-- + +Your `for` loop should not check if `i` is less than `count`. + +```js +assert.notMatch(code, /i\s*<\s*count/); +``` + +Your `for` loop should check if `i` is less than or equal to `count`. + +```js +assert.match(code, /i\s*<=\s*count/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +--fcc-editable-region-- +for (let i = 1; i < count; i++) { + rows.push(padRow(i, count)); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3ce51f70571e1c5227c8.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3ce51f70571e1c5227c8.md new file mode 100644 index 00000000000..b3d8d3fb9ec --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3ce51f70571e1c5227c8.md @@ -0,0 +1,57 @@ +--- +id: 660f3ce51f70571e1c5227c8 +title: Step 69 +challengeType: 0 +dashedName: step-69 +--- + +# --description-- + +Comments can be helpful for explaining why your code takes a certain approach, or leaving to-do notes for your future self. + +In JavaScript, you can use `//` to leave a single-line comment in your code. + +Add a single-line comment above your function to remind yourself to change the code to a different kind of loop. + +# --hints-- + +You should start a single-line comment with `//`. + +```js +assert.match(code, /\/\//); +``` + +Your single-line comment should be at least five characters long. + +```js +assert.match(code, /\/\/.{5,}/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +--fcc-editable-region-- + +for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3dd626be3a1ffe27e5d1.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3dd626be3a1ffe27e5d1.md new file mode 100644 index 00000000000..24e001bd9c7 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f3dd626be3a1ffe27e5d1.md @@ -0,0 +1,66 @@ +--- +id: 660f3dd626be3a1ffe27e5d1 +title: Step 70 +challengeType: 0 +dashedName: step-70 +--- + +# --description-- + +JavaScript also has support for multi-line comments. A multi-line comment starts with `/*` and ends with `*/`. + +Unlike a single-line comment, a multi-line comment will encapsulate multiple lines. + +Use `/*` and `*/` to turn your current `for` loop, including the body, into a multi-line comment. + +# --hints-- + +You should start a multi-line comment with `/*`. + +```js +assert.match(code, /\/\*/); +``` + +You should end a multi-line comment with `*/`. + +```js +assert.match(code, /\*\//); +``` + +Your entire `for` loop should be commented out. + +```js +const stripped = __helpers.removeJSComments(code); +assert.lengthOf(stripped.match(/for/g), 1); +assert.notMatch(stripped, /rows\.push/); +assert.notMatch(stripped, /i <= count/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +--fcc-editable-region-- +for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f415b76859a2736771607.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f415b76859a2736771607.md new file mode 100644 index 00000000000..af25aeed3e0 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f415b76859a2736771607.md @@ -0,0 +1,71 @@ +--- +id: 660f415b76859a2736771607 +title: Step 71 +challengeType: 0 +dashedName: step-71 +--- + +# --description-- + +Your pyramid has disappeared again. That's okay - that is to be expected. + +Before you create your new loop, you need to learn about `if` statements. An `if` statement allows you to run a block of code only when a condition is met. They use the following syntax: + +```js +if (condition) { + logic +} +``` + +Create an `if` statement with the boolean `true` as the condition. In the body, print the string `"Condition is true"`. + +# --hints-- + +You should create an `if` statement. + +```js +assert.match(code, /if/); +``` + +Your `if` statement should have `true` as the condition. + +```js +assert.match(code, /if\s*\(\s*true\s*\)/); +``` + +Your `if` body should log `"Condition is true"`. + +```js +assert.match(code, /if\s*\(\s*true\s*\)\s*\{\s*console\.log\(\s*("|')Condition is true\1\s*\);?/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +--fcc-editable-region-- + +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4377a359972c521d3f4b.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4377a359972c521d3f4b.md new file mode 100644 index 00000000000..10bcc18cd97 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4377a359972c521d3f4b.md @@ -0,0 +1,53 @@ +--- +id: 660f4377a359972c521d3f4b +title: Step 72 +challengeType: 0 +dashedName: step-72 +--- + +# --description-- + +You'll see the string printed in the console, because `true` is in fact true. + +Change the condition of your `if` statement to the boolean `false`. + +# --hints-- + +Your `if` condition should have `false` as the condition. + +```js +assert.match(code, /if\s*\(\s*false\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +--fcc-editable-region-- +if (true) { + console.log("Condition is true"); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4455f457ef2e3ec6920f.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4455f457ef2e3ec6920f.md new file mode 100644 index 00000000000..81d53718a72 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4455f457ef2e3ec6920f.md @@ -0,0 +1,53 @@ +--- +id: 660f4455f457ef2e3ec6920f +title: Step 73 +challengeType: 0 +dashedName: step-73 +--- + +# --description-- + +Now the string is no longer printing, because `false` is not `true`. But what about other values? + +Try changing the condition to the string `"false"`. + +# --hints-- + +Your `if` statement should have the string `"false"` as the condition. + +```js +assert.match(code, /if\s*\(\s*('|")false\1\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +--fcc-editable-region-- +if (false) { + console.log("Condition is true"); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f447efc0e722f016c1be0.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f447efc0e722f016c1be0.md new file mode 100644 index 00000000000..038b07f5cc8 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f447efc0e722f016c1be0.md @@ -0,0 +1,57 @@ +--- +id: 660f447efc0e722f016c1be0 +title: Step 74 +challengeType: 0 +dashedName: step-74 +--- + +# --description-- + +The text has appeared again! This is because `"false"` is a string, which when evaluated to a boolean becomes `true`. This means `"false"` is a truthy value. + +A truthy value is a value that is considered true when evaluated as a boolean. Most of the values you encounter in JavaScript will be truthy. + +A falsy value is the opposite - a value considered false when evaluated as a boolean. JavaScript has a defined list of falsy values. Some of them include `false`, `0`, `""`, `null`, `undefined`, and `NaN`. + +Try changing your `if` condition to an empty string `""`, which is a falsy value. + +# --hints-- + +Your `if` statement should have `""` as the condition. + +```js +assert.match(code, /if\s*\(\s*("|')\1\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +--fcc-editable-region-- +if ("false") { + console.log("Condition is true"); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f44f10ea40f300b896a5e.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f44f10ea40f300b896a5e.md new file mode 100644 index 00000000000..97a31f3606f --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f44f10ea40f300b896a5e.md @@ -0,0 +1,77 @@ +--- +id: 660f44f10ea40f300b896a5e +title: Step 75 +challengeType: 0 +dashedName: step-75 +--- + +# --description-- + +The text is gone again! Empty strings evaluate to `false`, making them a falsy value. You will learn more about truthy and falsy values in future projects. + +For now, remove your `if` statement entirely. Use `let` to declare a `continueLoop` variable and assign it the boolean `false`. Then use `let` to declare a `done` variable and assign it the value `0`. + +# --hints-- + +You should not have an `if` statement. + +```js +assert.notMatch(code, /if\s*\(/); +``` + +You should use `let` to declare a `continueLoop` variable. + +```js +assert.match(code, /let\s+continueLoop/); +``` + +Your `continueLoop` variable should have the value `false`. + +```js +assert.isFalse(continueLoop); +``` + +You should use `let` to declare a `done` variable. + +```js +assert.match(code, /let\s+done/); +``` + +Your `done` variable should have the value `0`. + +```js +assert.equal(done, 0); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +--fcc-editable-region-- +if ("") { + console.log("Condition is true"); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f455b044d3230ed971e98.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f455b044d3230ed971e98.md new file mode 100644 index 00000000000..22229053f83 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f455b044d3230ed971e98.md @@ -0,0 +1,65 @@ +--- +id: 660f455b044d3230ed971e98 +title: Step 76 +challengeType: 0 +dashedName: step-76 +--- + +# --description-- + +A `while` loop will run over and over again until the `condition` specified is no longer true. It has the following syntax: + +```js +while (condition) { + logic; +} +``` + +Use that syntax to declare a `while` loop with `continueLoop` as the condition. The body should be empty. + +# --hints-- + +You should use a `while` loop. + +```js +assert.match(code, /while/); +``` + +Your `while` loop should use `continueLoop` as the condition. + +```js +assert.match(code, /while\s*\(\s*continueLoop\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +--fcc-editable-region-- +let continueLoop = false; +let done = 0; + +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f45ccf4ca5c31f253005a.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f45ccf4ca5c31f253005a.md new file mode 100644 index 00000000000..7fdca07d541 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f45ccf4ca5c31f253005a.md @@ -0,0 +1,56 @@ +--- +id: 660f45ccf4ca5c31f253005a +title: Step 77 +challengeType: 0 +dashedName: step-77 +--- + +# --description-- + +Right now, if you change `continueLoop` to true, your `while` loop will run forever. This is called an infinite loop, and you should be careful to avoid these. An infinite loop can lock up your system, requiring a full restart to escape. + +To avoid this, start by using the increment operator to increase the value of the `done` variable inside your loop. + +# --hints-- + +Your `while` loop should increment the `done` variable. + +```js +assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +let continueLoop = false; +let done = 0; + +--fcc-editable-region-- +while (continueLoop) { + +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f46460f9c36330ebc07d8.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f46460f9c36330ebc07d8.md new file mode 100644 index 00000000000..2c559f09b26 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f46460f9c36330ebc07d8.md @@ -0,0 +1,61 @@ +--- +id: 660f46460f9c36330ebc07d8 +title: Step 79 +challengeType: 0 +dashedName: step-79 +--- + +# --description-- + +The equality operator can lead to some strange behavior in JavaScript. For example, `"0" == 0` is true, even though one is a string and one is a number. + +The strict equality operator `===` is used to check if two values are equal and share the same type. As a general rule, this is the equality operator you should always use. With the strict equality operator, `"0" === 0` becomes false, because while they might have the same value of zero, they are not of the same type. + +Update your `done == count` condition to use the strict equality operator. + +# --hints-- + +Your `if` condition should use strict equality. + +```js +assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*if\s*\(\s*(?:done\s*===\s*count|count\s*===\s*done)\s*\)\s*\{/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +let continueLoop = false; +let done = 0; + +while (continueLoop) { + done++; +--fcc-editable-region-- + if (done == count) { + + } +--fcc-editable-region-- +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f46b9c417a8341729a3ab.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f46b9c417a8341729a3ab.md new file mode 100644 index 00000000000..3d74b015a47 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f46b9c417a8341729a3ab.md @@ -0,0 +1,59 @@ +--- +id: 660f46b9c417a8341729a3ab +title: Step 80 +challengeType: 0 +dashedName: step-80 +--- + +# --description-- + +When `done` has reached the value of `count`, we want the loop to stop executing. + +Inside your `if` body, assign the boolean `false` to your `continueLoop` variable. + +# --hints-- + +Your `if` body should assign `false` to your `continueLoop` variable. + +```js +assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*if\s*\(\s*(?:done\s*===\s*count|count\s*===\s*done)\s*\)\s*\{\s*continueLoop\s*=\s*false;?/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +let continueLoop = false; +let done = 0; + +while (continueLoop) { + done++; +--fcc-editable-region-- + if (done === count) { + + } +--fcc-editable-region-- +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4774e3e0df35a68bb5f2.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4774e3e0df35a68bb5f2.md new file mode 100644 index 00000000000..aa7120fc73a --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4774e3e0df35a68bb5f2.md @@ -0,0 +1,76 @@ +--- +id: 660f4774e3e0df35a68bb5f2 +title: Step 81 +challengeType: 0 +dashedName: step-81 +--- + +# --description-- + +To make your pyramid generate again, push the result of calling `padRow` with `done` and `count` as the arguments to your `rows` array, similar to what you did in your first loop. + +# --hints-- + +Your loop should call the `.push()` method on your `rows`. + +```js +assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*rows\.push\(/); +``` + +You should call your `padRow` function in your `.push()` method. + +```js +assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*rows\.push\(\s*padRow\(/); +``` + +You should pass `done` as the first argument to your `padRow` call. + +```js +assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*rows\.push\(\s*padRow\(\s*done/); +``` + +You should pass `count` as the second argument to your `padRow` call. + +```js +assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*rows\.push\(\s*padRow\(\s*done\s*,\s*count\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +let continueLoop = false; +let done = 0; + +while (continueLoop) { + done++; +--fcc-editable-region-- + +--fcc-editable-region-- +if (done === count) { + continueLoop = false; + } +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f47afe4c98536715d5fa4.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f47afe4c98536715d5fa4.md new file mode 100644 index 00000000000..de47a64d5a7 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f47afe4c98536715d5fa4.md @@ -0,0 +1,60 @@ +--- +id: 660f47afe4c98536715d5fa4 +title: Step 82 +challengeType: 0 +dashedName: step-82 +--- + +# --description-- + +The strict inequality operator `!==` allows you to check if two values are not equal, or do not have the same type. The syntax is similar to the equality operator: `value !== 4`. + +Update your `while` loop condition to check if `done` is not equal to `count`. + +# --hints-- + +Your `while` loop should check if `done` and `count` are not equal. + +```js +assert.match(code, /while\s*\(\s*(?:done\s*!==\s*count|count\s*!==\s*done)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +let continueLoop = false; +let done = 0; + +--fcc-editable-region-- +while (continueLoop) { + done++; + rows.push(padRow(done, count)); +if (done === count) { + continueLoop = false; + } +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f487dc0c8fa38084f9754.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f487dc0c8fa38084f9754.md new file mode 100644 index 00000000000..6d709686e83 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f487dc0c8fa38084f9754.md @@ -0,0 +1,64 @@ +--- +id: 660f487dc0c8fa38084f9754 +title: Step 83 +challengeType: 0 +dashedName: step-83 +--- + +# --description-- + +Since you have moved the comparison into the `while` condition, you can remove your entire `if` statement. + +# --hints-- + +You should no longer have an `if` statement. + +```js +assert.notMatch(code, /if\s*\(\s*done\)/); +``` + +You should no longer set `continueLoop` to `false`. + +```js +assert.lengthOf(code.match(/continueLoop\s*=\s*false/g), 1); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +let continueLoop = false; +let done = 0; + +--fcc-editable-region-- +while (done !== count) { + done++; + rows.push(padRow(done, count)); +if (done === count) { + continueLoop = false; + } +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f48a419b40238e2b8b4d5.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f48a419b40238e2b8b4d5.md new file mode 100644 index 00000000000..5b84929842b --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f48a419b40238e2b8b4d5.md @@ -0,0 +1,57 @@ +--- +id: 660f48a419b40238e2b8b4d5 +title: Step 84 +challengeType: 0 +dashedName: step-84 +--- + +# --description-- + +Your loop is no longer relying on the `continueLoop` variable. This makes the variable an unused declaration. Generally, you want to avoid unused declarations to prevent future confusion. + +Remove your `continueLoop` variable. + +# --hints-- + +You should no longer have a `continueLoop` variable. + +```js +assert.notMatch(code, /continueLoop/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +--fcc-editable-region-- +let continueLoop = false; +let done = 0; + +while (done !== count) { + done++; + rows.push(padRow(done, count)); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f48e1d3682f39e81843c4.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f48e1d3682f39e81843c4.md new file mode 100644 index 00000000000..2ecdca347a5 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f48e1d3682f39e81843c4.md @@ -0,0 +1,58 @@ +--- +id: 660f48e1d3682f39e81843c4 +title: Step 85 +challengeType: 0 +dashedName: step-85 +--- + +# --description-- + +Your pyramid generator is still working. However, it could be possible to end up with an infinite loop again. + +Because you are only checking if `done` is not equal to `count`, if `done` were to be **larger** than `count` your loop would go on forever. + +Update your loop's condition to check if `done` is less than or equal to `count`. + +# --hints-- + +Your `while` loop should check if `done` is less than or equal to `count`. + +```js +assert.match(code, /while\s*\(\s*done\s*<=\s*count\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +--fcc-editable-region-- +let done = 0; + +while (done !== count) { + done++; + rows.push(padRow(done, count)); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4934fb48f63abd5ae371.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4934fb48f63abd5ae371.md new file mode 100644 index 00000000000..7480f3a9f9b --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4934fb48f63abd5ae371.md @@ -0,0 +1,58 @@ +--- +id: 660f4934fb48f63abd5ae371 +title: Step 86 +challengeType: 0 +dashedName: step-86 +--- + +# --description-- + +Using `done` to track the number of rows that have been generated is functional, but you can actually clean up the logic a bit further. + +Arrays have a special `length` property that allows you to see how many values, or elements, are in the array. You would access this property using syntax like `myArray.length`. + +Update your condition to check if `rows.length` is less than or equal to `count`. + +# --hints-- + +Your `while` loop should check if `rows.length` is less than or equal to `count`. + +```js +assert.match(code, /while\s*\(\s*rows\.length\s*<=\s*count\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +--fcc-editable-region-- +let done = 0; + +while (done <= count) { + done++; + rows.push(padRow(done, count)); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4990b1caa03b9dc97a43.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4990b1caa03b9dc97a43.md new file mode 100644 index 00000000000..80b30184e09 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4990b1caa03b9dc97a43.md @@ -0,0 +1,60 @@ +--- +id: 660f4990b1caa03b9dc97a43 +title: Step 88 +challengeType: 0 +dashedName: step-88 +--- + +# --description-- + +Now you no longer need your `done` variable. Remove the increment operation from your loop, and the variable declaration for `done`. + +# --hints-- + +You should not increment the `done` variable. + +```js +assert.notMatch(code, /done\+\+/); +``` + +You should no longer have a `done` variable. + +```js +assert.notMatch(code, /done/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +--fcc-editable-region-- +let done = 0; + +while (rows.length < count) { + done++; + rows.push(padRow(rows.length + 1, count)); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f49e32001983c90b75850.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f49e32001983c90b75850.md new file mode 100644 index 00000000000..41acdb3fae6 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f49e32001983c90b75850.md @@ -0,0 +1,61 @@ +--- +id: 660f49e32001983c90b75850 +title: Step 89 +challengeType: 0 +dashedName: step-89 +--- + +# --description-- + +That's a very clean and functional loop. Nice work! But there's still more to explore. + +Use a multi-line comment to comment out your `while` loop. + +# --hints-- + +Your `while` loop should be commented out. + +```js +const stripped = __helpers.removeJSComments(code); +assert.notMatch(stripped, /while/); +``` + +Your `while` loop body should be commented out. + +```js +const stripped = __helpers.removeJSComments(code); +assert.notMatch(stripped, /rows\.push/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +--fcc-editable-region-- +while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4a1472f8e63d76162ce5.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4a1472f8e63d76162ce5.md new file mode 100644 index 00000000000..862e8e41159 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4a1472f8e63d76162ce5.md @@ -0,0 +1,75 @@ +--- +id: 660f4a1472f8e63d76162ce5 +title: Step 90 +challengeType: 0 +dashedName: step-90 +--- + +# --description-- + +What if you made your pyramid upside-down, or inverted? Time to try it out! + +Start by creating a new `for` loop. Declare your iterator `i` and assign it the value of `count`, then use the boolean `false` for your condition and iteration statements. + +# --hints-- + +Your code should have a `for` loop. + +```js +const stripped = __helpers.removeJSComments(code); +assert.match(stripped, /for\s*\(/); +``` + +Your `for` loop should initialise `i` with the value of `count`. + +```js +assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count/); +``` + +Your `for` loop should use `false` as the condition. + +```js +assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*false/); +``` + + +Your `for` loop should use `false` as the iteration. + +```js +assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*false\s*;\s*false\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +--fcc-editable-region-- + +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4a83373de83ea101685f.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4a83373de83ea101685f.md new file mode 100644 index 00000000000..f2afb05a763 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4a83373de83ea101685f.md @@ -0,0 +1,57 @@ +--- +id: 660f4a83373de83ea101685f +title: Step 91 +challengeType: 0 +dashedName: step-91 +--- + +# --description-- + +Because you are going to loop in the opposite direction, your loop needs to run while `i` is greater than `0`. You can use the greater than operator `>` for this. + +Set your loop's condition to run when `i` is greater than `0`. + +# --hints-- + +Your `for` loop should run when `i` is greater than `0`. + +```js +assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*false\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +--fcc-editable-region-- +for (let i = count; false; false) { + +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4ae5b3924c3fc3373973.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4ae5b3924c3fc3373973.md new file mode 100644 index 00000000000..824ba99319a --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4ae5b3924c3fc3373973.md @@ -0,0 +1,57 @@ +--- +id: 660f4ae5b3924c3fc3373973 +title: Step 92 +challengeType: 0 +dashedName: step-92 +--- + +# --description-- + +Your iteration statement is also going to be different. Instead of adding `1` to `i` with each loop, you need to subtract `1`. + +Like you did earlier with `i = i + 1`, update your iteration statement to give `i` the value of subtracting `1` from itself. + +# --hints-- + +Your `for` loop should use `i = i - 1` as the iteration. + +```js +assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +--fcc-editable-region-- +for (let i = count; i > 0; false) { + +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4b33e2a3364094ecb540.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4b33e2a3364094ecb540.md new file mode 100644 index 00000000000..ca4d4311a81 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4b33e2a3364094ecb540.md @@ -0,0 +1,76 @@ +--- +id: 660f4b33e2a3364094ecb540 +title: Step 93 +challengeType: 0 +dashedName: step-93 +--- + +# --description-- + +Again, push the result of calling `padRow` with your `i` and `count` variables to your `rows` array. + +Open up the console to see the upside-down pyramid. + +# --hints-- + +Your `for` loop should call `rows.push()`. + +```js +assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)\s*\{\s*rows\.push\(/); +``` + +You should call `padRow()` in your `.push()` call. + +```js +assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(/); +``` + +You should pass `i` as the first argument to your `padRow()` call. + +```js +assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i/); +``` + +You should pass `count` as the second argument to your `padRow()` call. + +```js +assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i\s*,\s*count\s*\)\s*\)/); +``` + + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +--fcc-editable-region-- +for (let i = count; i > 0; i = i - 1) { + +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4b641290da41b2cf0dd9.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4b641290da41b2cf0dd9.md new file mode 100644 index 00000000000..1249513fd6d --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4b641290da41b2cf0dd9.md @@ -0,0 +1,63 @@ +--- +id: 660f4b641290da41b2cf0dd9 +title: Step 94 +challengeType: 0 +dashedName: step-94 +--- + +# --description-- + +Just like addition, there are different operators you can use for subtraction. The subtraction assignment operator `-=` subtracts the given value from the current variable value, then assigns the result back to the variable. + +Replace your iterator statement with the correct statement using the subtraction assignment operator. + +# --hints-- + +Your `for` loop should not use `i = i - 1`. + +```js +assert.notMatch(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*=\s*i\s*-\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i\s*,\s*count\s*\)\s*\);/); +``` + +Your `for` loop should use subtraction assignment to reduce `i` by `1`. + +```js +assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*-=\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i\s*,\s*count\s*\)\s*\);/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +--fcc-editable-region-- +for (let i = count; i > 0; i = i - 1) { + rows.push(padRow(i, count)); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4c3b01c44743719c99e4.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4c3b01c44743719c99e4.md new file mode 100644 index 00000000000..e15b856a658 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4c3b01c44743719c99e4.md @@ -0,0 +1,63 @@ +--- +id: 660f4c3b01c44743719c99e4 +title: Step 95 +challengeType: 0 +dashedName: step-95 +--- + +# --description-- + +Because you are only subtracting one from `i`, you can use the decrement operator `--`. + +Replace your subtraction assignment with the decrement operator. + +# --hints-- + +Your `for` loop should not use subtraction assignment. + +```js +assert.notMatch(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i\s*-=\s*1\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i\s*,\s*count\s*\)\s*\);/); +``` + +Your `for` loop should use the decrement operator. + +```js +assert.match(code, /for\s*\(\s*let\s*i\s*=\s*count\s*;\s*i\s*>\s*0\s*;\s*i--\s*\)\s*\{\s*rows\.push\(\s*padRow\s*\(\s*i\s*,\s*count\s*\)\s*\);/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +--fcc-editable-region-- +for (let i = count; i > 0; i -= 1) { + rows.push(padRow(i, count)); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4cde8dd305450514a1cb.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4cde8dd305450514a1cb.md new file mode 100644 index 00000000000..4378aea4c12 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4cde8dd305450514a1cb.md @@ -0,0 +1,63 @@ +--- +id: 660f4cde8dd305450514a1cb +title: Step 96 +challengeType: 0 +dashedName: step-96 +--- + +# --description-- + +Use a multi-line comment to comment out this loop as well, to prepare for the next approach. + +# --hints-- + +Your `for` loop should be commented out. + +```js +const stripped = __helpers.removeJSComments(code); +assert.lengthOf(stripped.match(/for\s*\(/), 1); +``` + +Your `for` loop body should be commented out. + +```js +const stripped = __helpers.removeJSComments(code); +assert.notMatch(stripped, /rows\.push/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +--fcc-editable-region-- +for (let i = count; i > 0; i--) { + rows.push(padRow(i, count)); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4cffb1459d45e34902d1.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4cffb1459d45e34902d1.md new file mode 100644 index 00000000000..061125e3e0b --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4cffb1459d45e34902d1.md @@ -0,0 +1,77 @@ +--- +id: 660f4cffb1459d45e34902d1 +title: Step 97 +challengeType: 0 +dashedName: step-97 +--- + +# --description-- + +You can actually build the inverted pyramid without needing to loop "backwards" like you did. + +To do this, you'll need to learn a couple of new array methods. Start by using `const` to declare a `numbers` variable. Assign it an array with the elements `1`, `2`, and `3`. Then log the `numbers` array. + +# --hints-- + +You should use `const` to declare a `numbers` variable. + +```js +assert.match(code, /const\s+numbers/); +``` + +Your `numbers` variable should be an array. + +```js +assert.isArray(numbers); +``` + +Your `numbers` array should have the elements `1`, `2`, and `3` in that order. + +```js +assert.deepEqual(numbers, [1,2,3]); +``` + +You should log your `numbers` array. + +```js +assert.match(code, /console\.log\(\s*numbers\s*\);?/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +/*for (let i = count; i > 0; i--) { + rows.push(padRow(i, count)); +}*/ + +--fcc-editable-region-- + +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4de78f775e480ba2e451.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4de78f775e480ba2e451.md new file mode 100644 index 00000000000..5592df6525b --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4de78f775e480ba2e451.md @@ -0,0 +1,86 @@ +--- +id: 660f4de78f775e480ba2e451 +title: Step 98 +challengeType: 0 +dashedName: step-98 +--- + +# --description-- + +The `.unshift()` method of an array allows you to add a value to the **beginning** of the array, unlike `.push()` which adds the value at the end of the array. Here is an example: + +```js +const numbers = [1, 2, 3]; +numbers.unshift(5); +``` + +The `numbers` array would now be `[5, 1, 2, 3]`. + +Use `const` to declare an `unshifted` variable, and assign it the result of calling `.unshift()` on your `numbers` array. Pass `5` as the argument. Then print your `unshifted` variable. + +# --hints-- + +You should declare your `unshifted` variable. + +```js +assert.match(code, /const\s+unshifted/); +``` + +You should call the `.unshift()` method on your `numbers` array. + +```js +assert.match(code, /numbers\.unshift\(/); +``` + +You should pass `5` as the argument to your `.unshift()` call. + +```js +assert.deepEqual(numbers, [5,1,2,3]); +``` + +You should assign the result of your `.unshift()` call to your `unshifted` variable. + +```js +assert.equal(unshifted, 4); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +/*for (let i = count; i > 0; i--) { + rows.push(padRow(i, count)); +}*/ + +--fcc-editable-region-- +const numbers = [1, 2, 3]; + +console.log(numbers); +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4e74f7fd3f4a99ac2e50.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4e74f7fd3f4a99ac2e50.md new file mode 100644 index 00000000000..65389830679 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4e74f7fd3f4a99ac2e50.md @@ -0,0 +1,91 @@ +--- +id: 660f4e74f7fd3f4a99ac2e50 +title: Step 99 +challengeType: 0 +dashedName: step-99 +--- + +# --description-- + +Notice that like `.push()`, `.unshift()` returns the new length of the array after the element is added. + +Arrays also have a `.shift()` method. This will remove the **first** element of the array, unlike `.pop()` which removes the last element. Here is an example of the `.shift()` method: + +```js +const numbers = [1, 2, 3]; +numbers.shift(); +``` + +The `numbers` array would be `[2, 3]`. + +Declare a `shifted` variable, assign it the result of calling `.shift()` on your `numbers` array, and print the variable. + +# --hints-- + +You should use `const` to declare a `shifted` variable. + +```js +assert.match(code, /const\s+shifted/); +``` + +You should call `.shift()` on your `numbers` array. + +```js +assert.deepEqual(numbers, [5, 2, 3]); +``` + +You should assign the result of your `.shift()` call to your `shifted` variable. + +```js +assert.equal(shifted, 1); +``` + +You should log your `shifted` variable. + +```js +assert.match(code, /console\.log\(\s*shifted\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +/*for (let i = count; i > 0; i--) { + rows.push(padRow(i, count)); +}*/ + +--fcc-editable-region-- +const numbers = [1, 2, 3]; + + +const unshifted = numbers.unshift(5); +console.log(unshifted); +console.log(numbers); +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4efcb8068e4cb470dca1.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4efcb8068e4cb470dca1.md new file mode 100644 index 00000000000..3e8a6b4282e --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4efcb8068e4cb470dca1.md @@ -0,0 +1,82 @@ +--- +id: 660f4efcb8068e4cb470dca1 +title: Step 100 +challengeType: 0 +dashedName: step-100 +--- + +# --description-- + +Now that you've tried these methods, you can do another inverted pyramid approach. But first you need to clean up your experimentation. + +Remove your `numbers` array, and the method calls and log calls. + +# --hints-- + +You should not have a `numbers` array. + +```js +assert.notMatch(code, /numbers/); +``` + +You should not have an `unshifted` variable. + +```js +assert.notMatch(code, /unshifted/); +``` + +You should not have a `shifted` variable. + +```js +assert.notMatch(code, /shifted/); +``` + +You should not have your `console.log` statements. + +```js +assert.lengthOf(code.match(/console\.log/g), 1); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +/*for (let i = count; i > 0; i--) { + rows.push(padRow(i, count)); +}*/ + +--fcc-editable-region-- +const numbers = [1, 2, 3]; +const shifted = numbers.shift(); +console.log(shifted); +const unshifted = numbers.unshift(5); +console.log(unshifted); +console.log(numbers); +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4f79e2a82a4e92290f44.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4f79e2a82a4e92290f44.md new file mode 100644 index 00000000000..371227400df --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f4f79e2a82a4e92290f44.md @@ -0,0 +1,78 @@ +--- +id: 660f4f79e2a82a4e92290f44 +title: Step 101 +challengeType: 0 +dashedName: step-101 +--- + +# --description-- + +Sometimes you may wish to bring back previous code that you commented out. You can do so by removing the `/*` and `*/` around that code. This is called uncommenting. + +Uncomment only your first `for` loop. Leave the single line comment and the other two multi line comments in place. + +# --hints-- + +You should uncomment your first `for` loop. + +```js +const stripped = __helpers.removeJSComments(code); +assert.match(stripped, /for\s*\(\s*let\s+i\s*=\s*1;\s*i\s*<=\s*count;\s*i\+\+\s*\)/) +``` + +You should not remove your single-line comment. + +```js +assert.match(code, /\/\/\sTODO:/); +``` + +You should not uncomment your `while` loop. + +```js +const stripped = __helpers.removeJSComments(code); +assert.notMatch(stripped, /while/); +``` + +You should not uncomment your second `for` loop. + +```js +const stripped = __helpers.removeJSComments(code); +assert.lengthOf(stripped.match(/for\s*\(/g), 2) +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +--fcc-editable-region-- +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +/*for (let i = count; i > 0; i--) { + rows.push(padRow(i, count)); +}*/ +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f505d02b2bd513a1c3468.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f505d02b2bd513a1c3468.md new file mode 100644 index 00000000000..0daf9b0bb6d --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f505d02b2bd513a1c3468.md @@ -0,0 +1,76 @@ +--- +id: 660f505d02b2bd513a1c3468 +title: Step 102 +challengeType: 0 +dashedName: step-102 +--- + +# --description-- + +Your pyramid is no longer inverted. This is because you are adding new rows to the **end** of the array. + +Update your loop body to add new rows to the beginning of the array. + +# --hints-- + +You should use the `unshift` method of `rows`. + +```js +const stripped = __helpers.removeJSComments(code); +assert.match(stripped, /\.unshift/); +``` + +You should pass a `padRow()` call as the argument for your `.unshift()` method. + +```js +assert.match(code, /rows\.unshift\(\s*padRow\(/); +``` + +You should pass `i` as the first argument to your `padRow()` call. + +```js +assert.match(code, /rows\.unshift\(\s*padRow\(\s*i/) +``` + +You should pass `count` as the second argument to your `padRow()` call. + +```js +assert.match(code, /rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +--fcc-editable-region-- +for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +} +--fcc-editable-region-- + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +/*for (let i = count; i > 0; i--) { + rows.push(padRow(i, count)); +}*/ + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f50a21fe7645252804f2b.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f50a21fe7645252804f2b.md new file mode 100644 index 00000000000..ff51f3af61d --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f50a21fe7645252804f2b.md @@ -0,0 +1,64 @@ +--- +id: 660f50a21fe7645252804f2b +title: Step 103 +challengeType: 0 +dashedName: step-103 +--- + +# --description-- + +What if you had a way to toggle between an inverted pyramid and a standard pyramid? + +Start by declaring an `inverted` variable, and assigning it the value `true`. You are not changing this variable in your code, but you will need to use `let` so our tests can modify it later. + +# --hints-- + +You should declare an `inverted` variable with `let`. + +```js +assert.match(code, /let\s+inverted/); +``` + +You should initialise `inverted` with the value `true`. + +```js +assert.match(code, /let\s+inverted\s*=\s*true;?/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; +--fcc-editable-region-- + +--fcc-editable-region-- + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +for (let i = 1; i <= count; i++) { + rows.unshift(padRow(i, count)); +} + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +/*for (let i = count; i > 0; i--) { + rows.push(padRow(i, count)); +}*/ + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f5179b3b0ca558f6b4d4f.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f5179b3b0ca558f6b4d4f.md new file mode 100644 index 00000000000..abdce9cec07 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f5179b3b0ca558f6b4d4f.md @@ -0,0 +1,69 @@ +--- +id: 660f5179b3b0ca558f6b4d4f +title: Step 104 +challengeType: 0 +dashedName: step-104 +--- + +# --description-- + +Use an `if` statement to check if `inverted` is true. Remember that you do not need to use an equality operator here. + +# --hints-- + +You should use an `if` statement. + +```js +assert.match(code, /if\s*\(/); +``` + +Your `if` statement should check if `inverted` is `true`. + +```js +assert.match(code, /if\s*\(\s*inverted/); +``` + +Your `if` condition should not use any comparison operators. + +```js +assert.match(code, /if\s*\(\s*inverted\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; +let inverted = true; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +--fcc-editable-region-- +for (let i = 1; i <= count; i++) { + + rows.unshift(padRow(i, count)); +} +--fcc-editable-region-- + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +/*for (let i = count; i > 0; i--) { + rows.push(padRow(i, count)); +}*/ + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f51f1df0a8757934a5796.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f51f1df0a8757934a5796.md new file mode 100644 index 00000000000..c9a254ab766 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f51f1df0a8757934a5796.md @@ -0,0 +1,59 @@ +--- +id: 660f51f1df0a8757934a5796 +title: Step 105 +challengeType: 0 +dashedName: step-105 +--- + +# --description-- + +Now move your `.unshift()` call into your `if` block. + +# --hints-- + +Your `.unshift()` call should be in your `if` block. + +```js +assert.match(code, /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; +let inverted = true; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +--fcc-editable-region-- +for (let i = 1; i <= count; i++) { + if (inverted) { + + } + rows.unshift(padRow(i, count)); +} +--fcc-editable-region-- + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +/*for (let i = count; i > 0; i--) { + rows.push(padRow(i, count)); +}*/ + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f530d6e33d159e1bf4947.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f530d6e33d159e1bf4947.md new file mode 100644 index 00000000000..af9833ba5ed --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f530d6e33d159e1bf4947.md @@ -0,0 +1,77 @@ +--- +id: 660f530d6e33d159e1bf4947 +title: Step 106 +challengeType: 0 +dashedName: step-106 +--- + +# --description-- + +Sometimes you will want to run different code when an `if` condition is false. You can do this by adding an `else` block. An `else` block will only evaluate if the `if` block does not evaluate. + +The syntax to add an `else` block is: + +```js +if (condition) { + logic +} else { + logic +} +``` + +Add an `else` block to your `if` block. + +# --hints-- + +You should add an `else` block. + +```js +assert.match(code, /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{/); +``` + +Your `else` block should be empty. + +```js +assert.match(code, /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*\}/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; +let inverted = true; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +--fcc-editable-region-- +for (let i = 1; i <= count; i++) { + if (inverted) { + rows.unshift(padRow(i, count)); + } + +} +--fcc-editable-region-- + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +/*for (let i = count; i > 0; i--) { + rows.push(padRow(i, count)); +}*/ + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f535ec33a285b33af3774.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f535ec33a285b33af3774.md new file mode 100644 index 00000000000..6172f5d51ce --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f535ec33a285b33af3774.md @@ -0,0 +1,78 @@ +--- +id: 660f535ec33a285b33af3774 +title: Step 107 +challengeType: 0 +dashedName: step-107 +--- + +# --description-- + +When `inverted` is false, you want to build a standard pyramid. Use `.push()` like you have in previous steps to achieve this. + +# --hints-- + +You should call the `.push()` method of `rows` in your `else` block. + +```js +assert.match(code, /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*rows\.push\(\s*/); +``` + +You should pass a `padRow()` call as the argument for your `.unshift()` method. + +```js +assert.match(code, /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*rows\.push\(\s*padRow\(/); +``` + +You should pass `i` as the first argument to your `padRow()` call. + +```js +assert.match(code, /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*rows\.push\(\s*padRow\(\s*i/); +``` + +You should pass `count` as the second argument to your `padRow()` call. + +```js +assert.match(code, /if\s*\(\s*inverted\s*\)\s*\{\s*rows\.unshift\(\s*padRow\(\s*i\s*,\s*count\s*\)\s*\);\s*\}\s*else\s*\{\s*rows\.push\(\s*padRow\(\s*i\s*,\s*count\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; +let inverted = true; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +--fcc-editable-region-- +for (let i = 1; i <= count; i++) { + if (inverted) { + rows.unshift(padRow(i, count)); + } else { + + } +} +--fcc-editable-region-- + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +/*for (let i = count; i > 0; i--) { + rows.push(padRow(i, count)); +}*/ + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f53ad3d39175c5d4335ac.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f53ad3d39175c5d4335ac.md new file mode 100644 index 00000000000..48e960bc110 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f53ad3d39175c5d4335ac.md @@ -0,0 +1,74 @@ +--- +id: 660f53ad3d39175c5d4335ac +title: Step 108 +challengeType: 0 +dashedName: step-108 +--- + +# --description-- + +Your pyramid generator is now in a finished state, with more functionality than you originally planned! The next step is to clean up your code. + +Remove all comments, both single- and multi-line, from your code. + +# --hints-- + +You should not have any single-line comments in your code. + +```js +assert.notMatch(code, /\/\//); +``` + +You should not have any multi-line comments in your code. + +```js +assert.notMatch(code, /(?:\\\*|\/\*)/); +``` + +You should not have any comments in your code. + +```js +assert.equal(code, __helpers.removeJSComments(code)); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; +let inverted = true; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +--fcc-editable-region-- +// TODO: use a different type of loop +for (let i = 1; i <= count; i++) { + if (inverted) { + rows.unshift(padRow(i, count)); + } else { + rows.push(padRow(i, count)); + } +} + +/*while (rows.length < count) { + rows.push(padRow(rows.length + 1, count)); +}*/ + +/*for (let i = count; i > 0; i--) { + rows.push(padRow(i, count)); +}*/ +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f540c2176ea5dec01306d.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f540c2176ea5dec01306d.md new file mode 100644 index 00000000000..1124445d519 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/660f540c2176ea5dec01306d.md @@ -0,0 +1,96 @@ +--- +id: 660f540c2176ea5dec01306d +title: Step 109 +challengeType: 0 +dashedName: step-109 +--- + +# --description-- + +Nice work! Experiment with different values for your `character`, `count`, and `inverted` variables. + +When you are ready to move on to your next project, set `character` to `"!"`, `count` to `10`, and `inverted` to `false` to continue. + +Congratulations on completing your first JavaScript project! + +# --hints-- + +You should set `character` to `"!"`. + +```js +assert.equal(character, "!"); +``` + +You should set `count` to `10`. + +```js +assert.equal(count, 10); +``` + +You should set `inverted` to `false`. + +```js +assert.equal(inverted, false); +``` + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +const character = "#"; +const count = 8; +const rows = []; +let inverted = true; +--fcc-editable-region-- + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +for (let i = 1; i <= count; i++) { + if (inverted) { + rows.unshift(padRow(i, count)); + } else { + rows.push(padRow(i, count)); + } +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` + +# --solutions-- + +```js +const character = "!"; +const count = 10; +const rows = []; +let inverted = false; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +for (let i = 1; i <= count; i++) { + if (inverted) { + rows.unshift(padRow(i, count)); + } else { + rows.push(padRow(i, count)); + } +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610b741b54b90f0c0fb3d58.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610b741b54b90f0c0fb3d58.md new file mode 100644 index 00000000000..fa9f4cf744e --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610b741b54b90f0c0fb3d58.md @@ -0,0 +1,55 @@ +--- +id: 6610b741b54b90f0c0fb3d58 +title: Step 7 +challengeType: 0 +dashedName: step-7 +--- + +# --description-- + +When variable names are more than one word, there are specific naming conventions for how you capitalize the words. In JavaScript, the convention to use is camel case. + +Camel case means that the first word in the name is entirely lowercase, but the following words are all title-cased. Here are some examples of camel case: + +```js +let variableOne; +let secondVariable; +let yetAnotherVariable; +let thisIsAnAbsurdlyLongName; +``` + +Use camel case to declare a new `secondCharacter` variable. + +# --hints-- + +You should declare a `secondCharacter` variable. + +```js +assert.match(code, /secondCharacter/); +``` + +You should use `let` to declare your `secondCharacter` variable. + +```js +assert.match(code, /let\s+secondCharacter/); +``` + +You should not assign a value to your `secondCharacter` variable. Do not forget your semi-colon. + +```js +assert.match(code, /let\s+secondCharacter;/); +``` + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +let character = 'Hello'; +console.log(character); +character = "World"; +console.log(character); + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610b8017d1671f2814e8c77.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610b8017d1671f2814e8c77.md new file mode 100644 index 00000000000..6a56d73254f --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610b8017d1671f2814e8c77.md @@ -0,0 +1,40 @@ +--- +id: 6610b8017d1671f2814e8c77 +title: Step 8 +challengeType: 0 +dashedName: step-8 +--- + +# --description-- + +When you declare a variable without initializing it, it is considered uninitialized. Currently, your `secondCharacter` variable is uninitialized. + +Add a `console.log()` to see what the value of your `secondCharacter` variable is. + +# --hints-- + +You should add a second `console.log`. + +```js +assert.lengthOf(code.match(/console\.log/g), 2); +``` + +You should log your `secondCharacter` variable. + +```js +assert.match(code, /console\.log\(\s*secondCharacter\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +let character = 'Hello'; +console.log(character); +character = "World"; +let secondCharacter; + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610b8f6a98d25f4d485a94d.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610b8f6a98d25f4d485a94d.md new file mode 100644 index 00000000000..9c9eb49e6eb --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610b8f6a98d25f4d485a94d.md @@ -0,0 +1,54 @@ +--- +id: 6610b8f6a98d25f4d485a94d +title: Step 9 +challengeType: 0 +dashedName: step-9 +--- + +# --description-- + +The default value of an uninitialized variable is `undefined`. This is a special data type that represents a value that does not have a definition yet. + +You can still assign a value to an uninitialized variable. Here is an example: + +```js +let uninitialized; +uninitialized = "assigned"; +``` + +Assign the string `"Test"` to your `secondCharacter` variable below your declaration. Open the console to see how your log has changed. + +# --hints-- + +You should not initialize `secondCharacter`. Remember that initialization means assigning a value when you declare the variable. + +```js +assert.notMatch(code, /let\s+secondCharacter\s*=/); +``` + +You should use the assignment operator on `secondCharacter`. + +```js +assert.match(code, /secondCharacter\s*=/); +``` + +You should assign the string `"Test"` to your `secondCharacter` variable. + +```js +assert.equal(secondCharacter, "Test"); +``` + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- +let character = 'Hello'; +console.log(character); +character = "World"; +let secondCharacter; + +console.log(secondCharacter); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610b9f7619764fad5fd516d.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610b9f7619764fad5fd516d.md new file mode 100644 index 00000000000..83e656f2d0b --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610b9f7619764fad5fd516d.md @@ -0,0 +1,58 @@ +--- +id: 6610b9f7619764fad5fd516d +title: Step 10 +challengeType: 0 +dashedName: step-10 +--- + +# --description-- + +You can also assign the value of a variable to another variable. For example: + +```js +let first = "One"; +let second = "Two"; +second = first; +``` + +The `second` variable would now have the value `"One"`. + +To see this in action, change your `secondCharacter` assignment from `"Test"` to your `character` variable. + +Then open the console to see what gets logged. + +# --hints-- + +You should not assign the value `"Test"` to your `secondCharacter` variable. + +```js +assert.notEqual(secondCharacter, "Test"); +``` + +You should assign the value of the `character` variable to your `secondCharacter` variable. Don't forget your semi-colon. + +```js +assert.match(code, /secondCharacter\s*=\s*character;/); +``` + +Your `secondCharacter` variable should now have the value `"World"`. + + +```js +assert.equal(secondCharacter, "World"); +``` + +# --seed-- + +## --seed-contents-- + +```js +let character = 'Hello'; +console.log(character); +character = "World"; +let secondCharacter; +--fcc-editable-region-- +secondCharacter = "Test"; +--fcc-editable-region-- +console.log(secondCharacter); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610bbed59bc2a0194d85533.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610bbed59bc2a0194d85533.md new file mode 100644 index 00000000000..92cd9dfc29c --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610bbed59bc2a0194d85533.md @@ -0,0 +1,53 @@ +--- +id: 6610bbed59bc2a0194d85533 +title: Step 19 +challengeType: 0 +dashedName: step-19 +--- + +# --description-- + +Notice how the value inside your `rows` array has been changed directly? This is called mutation. As you learn more about arrays, you will learn when to mutate an array, and when you should not. + +Before moving on, this is a great opportunity to learn a common array use. Currently, your code accesses the last element in the array with `rows[2]`. But you may not know how many elements are in an array when you want the last one. + +You can make use of the `.length` property of an array - this returns the number of elements in the array. For example, your `rows` array has 3 elements, so `rows.length` would be `3`. + +Since you know the last element is at index `2`, you can compare that with the length of the array and see it is one less. The last element of an array will always be accessible at the index `length - 1`. You can use that in your bracket notation. + +Update your `rows[2]` to access the `rows.length - 1` index instead of the `2` index. You should not see anything change in your console. + +# --hints-- + +You should use the `.length` property of your `rows` array. + +```js +assert.match(code, /rows\.length/); +``` + +You should use `rows.length` in your bracket notation. + +```js +assert.match(code, /rows\[\s*rows\.length/); +``` + +You should subtract `1` from the length in your bracket notation. + +```js +assert.match(code, /rows\[\s*rows\.length\s*-\s*1\s*\]/) +``` + +# --seed-- + +## --seed-contents-- + +```js +let character = 'Hello'; +let count = 8; +let rows = ["Naomi", "Quincy", "CamperChan"]; +console.log(rows[0]); +--fcc-editable-region-- +rows[2] = 10; +--fcc-editable-region-- +console.log(rows); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610bf6fa14d700beed1b109.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610bf6fa14d700beed1b109.md new file mode 100644 index 00000000000..fb17f2395f0 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610bf6fa14d700beed1b109.md @@ -0,0 +1,63 @@ +--- +id: 6610bf6fa14d700beed1b109 +title: Step 78 +challengeType: 0 +dashedName: step-78 +--- + +# --description-- + +The equality operator `==` is used to check if two values are equal. To compare two values, you'd use a statement like `value == 8`. + +Add an `if` statement to your loop. The statement should check if `done` is equal to `count` using the equality operator. + +# --hints-- + +You should use an `if` statement in your loop. + +```js +assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*if/); +``` + +Your `if` statement should use the equality operator to compare `done` and `count` in the condition. + +```js +assert.match(code, /while\s*\(\s*continueLoop\s*\)\s*\{\s*done\+\+;\s*if\s*\(\s*(?:done\s*==\s*count|count\s*==\s*done)\s*\)\s*\{/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +let continueLoop = false; +let done = 0; + +--fcc-editable-region-- +while (continueLoop) { + done++; + +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c105bbdacc114d6cdc44.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c105bbdacc114d6cdc44.md new file mode 100644 index 00000000000..b4fa4b3195c --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c105bbdacc114d6cdc44.md @@ -0,0 +1,63 @@ +--- +id: 6610c105bbdacc114d6cdc44 +title: Step 43 +challengeType: 0 +dashedName: step-43 +--- + +# --description-- + +In order to use a function, you need to call it. A function call tells your application to run the code from the function wherever you choose to call it. The syntax for a function call is the function name followed by parentheses. For example, this code defines and calls a `test` function. + +```js +function test() { + +} +test(); +``` + +Call your `padRow` function. + +# --hints-- + +You should call the `padRow` function. + +```js +assert.lengthOf(code.match(/padRow\(\)/g), 2); +``` + +Your `padRow` function body should be empty. + +```js +assert.match(padRow.toString(), /\{\s*\}/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow() { + +} + +--fcc-editable-region-- + + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c16c4fa0df12c0e30675.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c16c4fa0df12c0e30675.md new file mode 100644 index 00000000000..98bf1305ffc --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c16c4fa0df12c0e30675.md @@ -0,0 +1,62 @@ +--- +id: 6610c16c4fa0df12c0e30675 +title: Step 44 +challengeType: 0 +dashedName: step-44 +--- + +# --description-- + +You are calling your `padRow` function, but not doing anything with that function call. All functions in JavaScript return a value, meaning they provide the defined result of calling them for you to use elsewhere. + +To see the result of calling your `padRow` function, declare a `call` variable and assign your existing `padRow` call to that variable. + +# --hints-- + +You should declare a `call` variable. + +```js +assert.match(code, /(const|let)\s+call/); +``` + +You should use `const` to declare your `call` variable. + +```js +assert.match(code, /const\s+call/); +``` + +You should assign `call` the result of your `padRow` call. + +```js +assert.match(code, /const\s+call\s*=\s*padRow\(\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow() { + +} +padRow(); +--fcc-editable-region-- + + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c1d97b1671140f95cfbb.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c1d97b1671140f95cfbb.md new file mode 100644 index 00000000000..51d60b26ea8 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c1d97b1671140f95cfbb.md @@ -0,0 +1,55 @@ +--- +id: 6610c1d97b1671140f95cfbb +title: Step 45 +challengeType: 0 +dashedName: step-45 +--- + +# --description-- + +Now add a log statement to print the value of your `call` variable. + +# --hints-- + +You should add a `console.log` call. + +```js +assert.lengthOf(code.match(/console\.log/g), 2) +``` + +You should log your `call` variable. Don't forget the semi-colon. + +```js +assert.match(code, /console\.log\(\s*call\s*\);/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow() { + +} +const call = padRow(); + +--fcc-editable-region-- + + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c21b3ef82015573ffbbe.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c21b3ef82015573ffbbe.md new file mode 100644 index 00000000000..af8e3181b86 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c21b3ef82015573ffbbe.md @@ -0,0 +1,65 @@ +--- +id: 6610c21b3ef82015573ffbbe +title: Step 46 +challengeType: 0 +dashedName: step-46 +--- + +# --description-- + +Your `call` variable has an `undefined` value, even though you defined it! This is because your `padRow` function does not currently return a value. By default, functions return `undefined` as their value. + +In order to return something else, you need to use the `return` keyword. Here is an example of a function that returns the string `"Functions are cool!"`: + +```js +function demo() { + return "Functions are cool!"; +} +``` + +Use the `return` keyword to have your function return the string `"Hello!"`. + +# --hints-- + +Your `padRow` function should use the `return` keyword. + +```js +assert.match(padRow.toString(), /return/); +``` + +Your `padRow` function should return the string `"Hello!"`. + +```js +assert.equal(padRow(), "Hello!"); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow() { + +} +--fcc-editable-region-- +const call = padRow(); +console.log(call); + + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c2d8d67563174fcf96dc.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c2d8d67563174fcf96dc.md new file mode 100644 index 00000000000..8e7648598f5 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c2d8d67563174fcf96dc.md @@ -0,0 +1,61 @@ +--- +id: 6610c2d8d67563174fcf96dc +title: Step 47 +challengeType: 0 +dashedName: step-47 +--- + +# --description-- + +When you have a value that is explicitly written in your code, like the `"Hello!"` string in your function, it is considered to be hard-coded. Hard-coding a value inside a function might not make it as reusable as you'd like. + +Instead, you can define parameters for the function. Parameters are special variables that are given a value when you call the function, and can be used in your function to dynamically change the result of the function's code. + +To add a parameter to your function, you need to add a variable name inside the parentheses. For example, this `demo` function has a `name` parameter: + +```js +function demo(name) { + +} +``` + +`name` sounds like a useful parameter, so go ahead and add it to your `padRow` function. + +# --hints-- + +Your `padRow` function should have a `name` parameter. + +```js +assert.match(padRow.toString(), /\(name\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow() { + return "Hello!"; +} +--fcc-editable-region-- +const call = padRow(); +console.log(call); + + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c424b7119919b62932f4.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c424b7119919b62932f4.md new file mode 100644 index 00000000000..e18c9cfef65 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c424b7119919b62932f4.md @@ -0,0 +1,51 @@ +--- +id: 6610c424b7119919b62932f4 +title: Step 48 +challengeType: 0 +dashedName: step-48 +--- + +# --description-- + +A function does not have to return a hard-coded value. It can return the value stored in a variable. Parameters are special variables for a function, so they can also be returned. + +Change your `padRow` function to `return` the `name` parameter directly. + +# --hints-- + +Your `padRow` function should return the value of the `name` parameter. + +```js +assert.equal(padRow("Naomi"), "Naomi"); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow(name) { + return "Hello!"; +} +--fcc-editable-region-- +const call = padRow(); +console.log(call); + + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c48c4ea0891afa7c4696.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c48c4ea0891afa7c4696.md new file mode 100644 index 00000000000..c013e33f861 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c48c4ea0891afa7c4696.md @@ -0,0 +1,60 @@ +--- +id: 6610c48c4ea0891afa7c4696 +title: Step 49 +challengeType: 0 +dashedName: step-49 +--- + +# --description-- + +If you open your console again, you'll see that your `padRow` function is returning `undefined`, even though you defined a return value! This is because parameters need to be given a value when you **call** the function. + +When you pass a value to a function call, that value is referred to as an argument. Here is an example of calling a `demo` function and passing `"Naomi"` as the argument for the `name` parameter. + +```js +function demo(name) { + return name; +} +demo("Naomi"); +``` + +Pass your own name as the argument for the `name` parameter in your `padRow` call. Remember that your name is a string, so you'll need to use quotes. + +# --hints-- + +You should pass a string to your `padRow()` call. + +```js +assert.match(code, /padRow\(\s*("|').+\1\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(name) { + return name; +} +--fcc-editable-region-- +const call = padRow(); +--fcc-editable-region-- +console.log(call); + + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c538372aa61cc0f5b122.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c538372aa61cc0f5b122.md new file mode 100644 index 00000000000..ef652edf1f5 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c538372aa61cc0f5b122.md @@ -0,0 +1,69 @@ +--- +id: 6610c538372aa61cc0f5b122 +title: Step 50 +challengeType: 0 +dashedName: step-50 +--- + +# --description-- + +Variables in JavaScript are available in a specific scope. In other words, where a variable is declared determines where in your code it can be used. + +The first scope is the global scope. Variables that are declared outside of any "block" like a function or `for` loop are in the global scope. Your `character`, `count`, and `rows` variables are all in the global scope. + +When a variable is in the global scope, a function can access it in its definition. Here is an example of a function using a global `title` variable: + +```js +const title = "Professor "; +function demo(name) { + return title + name; +} +demo("Naomi") +``` + +This example would return `"Professor Naomi"`. Update your `padRow` function to return the value of concatenating your `character` variable to the beginning of the `name` parameter. + +# --hints-- + +Your `padRow` function should concatenate `character` to the beginning of `name`. + +```js +assert.match(padRow.toString(), /character\s*\+\s*name/); +``` + +Your `padRow` function should return the result of `character + name`. + +```js +assert.equal(padRow("Naomi"), "#Naomi"); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow(name) { + return name; +} +--fcc-editable-region-- +const call = padRow("CamperChan"); +console.log(call); + + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c6541c82551f95e765ab.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c6541c82551f95e765ab.md new file mode 100644 index 00000000000..95e0d664173 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c6541c82551f95e765ab.md @@ -0,0 +1,61 @@ +--- +id: 6610c6541c82551f95e765ab +title: Step 51 +challengeType: 0 +dashedName: step-51 +--- + +# --description-- + +Variables can also be declared inside a function. These variables are considered to be in the local scope, or block scope. A variable declared inside a function can only be used inside that function. If you try to access it outside of the function, you will either get `undefined` or an error. + +To see this in action, use `const` to declare a `test` variable in your `padRow` function. Initialise it with the value `"Testing"`. + +Then, below your function, try to log `test` to the console. You will see an error because it is not defined outside of the function's local scope. Remove that `console.log` to pass the tests and continue. + +# --hints-- + +Your function should declare a `test` variable. + +```js +assert.match(padRow.toString(), /var\s+test/); +``` + +You should initialise `test` with the value `"Testing"`. Don't forget the semi-colon. + +```js +assert.match(padRow.toString(), /var\s+test\s*=\s*('|")Testing\1;/) +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow(name) { + return character + name; + +} + +--fcc-editable-region-- +const call = padRow("CamperChan"); +console.log(call); + + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c71600966a2191d3a64a.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c71600966a2191d3a64a.md new file mode 100644 index 00000000000..531a7287806 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c71600966a2191d3a64a.md @@ -0,0 +1,55 @@ +--- +id: 6610c71600966a2191d3a64a +title: Step 52 +challengeType: 0 +dashedName: step-52 +--- + +# --description-- + +There is a bit of a problem, here. Your `test` declaration is currently after your `return` statement. An important thing to know about the `return` keyword is that it does not just define a value to be returned from your function, it also stops the execution of your function code. This means that any code after a `return` statement will not run. + +Move your `test` initialization to the line above your `return` statement. + +# --hints-- + +Your `test` variable should come before your `return` keyword. + +```js +const str = padRow.toString(); +assert.isBelow(str.indexOf("test"), str.indexOf("return")); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow(name) { + + return character + name; + const test = "Testing"; +} + +--fcc-editable-region-- +const call = padRow("CamperChan"); +console.log(call); + + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c77d50636722e5b6be17.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c77d50636722e5b6be17.md new file mode 100644 index 00000000000..9ea609ce36a --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c77d50636722e5b6be17.md @@ -0,0 +1,53 @@ +--- +id: 6610c77d50636722e5b6be17 +title: Step 53 +challengeType: 0 +dashedName: step-53 +--- + +# --description-- + +If you try to add a `console.log(test)` call below your `padRow` function, you would see an error. This is because `test` is defined in the local scope, meaning you cannot access it in the global scope (outside of the `padRow` function). + +Returning a value from a function brings that value into the scope where the function was called. To bring your `"Testing"` value from the `padRow` function into the global scope, update your `return` statement to return only the `test` variable. + +# --hints-- + +Your `padRow` function should return the `test` variable. + +```js +assert.equal(padRow("Naomi"), "Testing"); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow(name) { + const test = "Testing"; + return character + name; +} + +--fcc-editable-region-- +const call = padRow("CamperChan"); +console.log(call); + + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c83b52583e245a079217.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c83b52583e245a079217.md new file mode 100644 index 00000000000..21a28932dce --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c83b52583e245a079217.md @@ -0,0 +1,63 @@ +--- +id: 6610c83b52583e245a079217 +title: Step 54 +challengeType: 0 +dashedName: step-54 +--- + +# --description-- + +Now your `call` variable has the value `"Testing"`. But your function is no longer using the `name` parameter. + +Remove the `name` parameter from your function declaration, then remove your `"CamperChan"` string from the `padRow` call. + +# --hints-- + +Your `padRow` function should not have a `name` parameter. + +```js +assert.notMatch(padRow.toString(), /name/); +``` + +You should not pass `"CamperChan"` to your `padRow` call. + +```js +assert.notMatch(code, /CamperChan/); +``` + +You should still call your `padRow` function. + +```js +assert.lengthOf(code.match(/padRow\(\)/g), 2); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow(name) { + const test = "Testing"; + return test; +} +const call = padRow("CamperChan"); +console.log(call); +--fcc-editable-region-- + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c87eac0f0b256d7b037e.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c87eac0f0b256d7b037e.md new file mode 100644 index 00000000000..da13242e1a0 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c87eac0f0b256d7b037e.md @@ -0,0 +1,57 @@ +--- +id: 6610c87eac0f0b256d7b037e +title: Step 55 +challengeType: 0 +dashedName: step-55 +--- + +# --description-- + +Because your function was no longer using the parameter, changing the value passed in the call did not affect it. + +Go ahead and remove the `test` declaration from your `padRow` function. Also, remove the `return` statement, so your function is empty again. + +# --hints-- + +Your `padRow` function should not have a `test` variable. + +```js +assert.notMatch(padRow.toString(), /test/); +``` + +Your `padRow` function should not return a value. + +```js +assert.notMatch(padRow.toString(), /return/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow() { + const test = "Testing"; + return test; +} +const call = padRow(); +console.log(call); +--fcc-editable-region-- + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c8cfe4cf4d278e35c156.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c8cfe4cf4d278e35c156.md new file mode 100644 index 00000000000..7c0b0f6f78f --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/6610c8cfe4cf4d278e35c156.md @@ -0,0 +1,54 @@ +--- +id: 6610c8cfe4cf4d278e35c156 +title: Step 56 +challengeType: 0 +dashedName: step-56 +--- + +# --description-- + +As expected, your function now returns `undefined` again. Your `call` variable is not necessary any more, so remove the `call` declaration and the `console.log` for the `call` variable. + +# --hints-- + +You should not have a `call` declaration. + +```js +assert.notMatch(code, /const\s*call/); +``` + +You should not log your `call` variable. + +```js +assert.notMatch(code, /call/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +--fcc-editable-region-- +function padRow() { + +} +const call = padRow(); +console.log(call); +--fcc-editable-region-- + +for (let i = 0; i < count; i = i + 1) { + rows.push(character.repeat(i + 1)) +} + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/661483051820c3c1ab4595e0.md b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/661483051820c3c1ab4595e0.md new file mode 100644 index 00000000000..95a504e23f4 --- /dev/null +++ b/curriculum/challenges/english/15-javascript-algorithms-and-data-structures-22/learn-introductory-javascript-by-building-a-pyramid-generator/661483051820c3c1ab4595e0.md @@ -0,0 +1,66 @@ +--- +id: 661483051820c3c1ab4595e0 +title: Step 87 +challengeType: 0 +dashedName: step-87 +--- + +# --description-- + +You can also replace the `done` reference in your `padRow` call. + +Note that `rows.length` here would give you an off-by-one error, because `done` is incremented *before* the call. + +So you'll need to replace `done` here with `rows.length + 1`. When you do this, you may see a `Range Error`, because we've created another off-by-one error. + +You'll need to change the `while` condition to use the less than operator, instead of the less than or equal operator. + +# --hints-- + +You should pass `rows.length + 1` as the first argument to your `padRow` call. + +```js +assert.match(code, /rows\.push\(padRow\s*\(\s*rows\.length\s*\+\s*1/); +``` + +Your `while` loop should run while `rows.length` is less than `count`. + +```js +assert.match(code, /while\s*\(\s*rows\.length\s*<\s*count\)/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const character = "#"; +const count = 8; +const rows = []; + +function padRow(rowNumber, rowCount) { + return " ".repeat(rowCount - rowNumber) + character.repeat(2 * rowNumber - 1) + " ".repeat(rowCount - rowNumber); +} + +// TODO: use a different type of loop +/*for (let i = 1; i <= count; i++) { + rows.push(padRow(i, count)); +}*/ + +--fcc-editable-region-- +let done = 0; + +while (rows.length <= count) { + done++; + rows.push(padRow(done, count)); +} +--fcc-editable-region-- + +let result = "" + +for (const row of rows) { + result = result + "\n" + row; +} + +console.log(result); +``` diff --git a/curriculum/dictionaries/english/comments-to-not-translate.json b/curriculum/dictionaries/english/comments-to-not-translate.json index 1c8390fa491..4d2f08c2a1f 100644 --- a/curriculum/dictionaries/english/comments-to-not-translate.json +++ b/curriculum/dictionaries/english/comments-to-not-translate.json @@ -8,5 +8,8 @@ "3q1p2l": "console.log(spreadsheetFunctions[\"random\"](1, 1000) === spreadsheetFunctions[\"random\"](1, 1000))", "gq2zsq": "window.onload();", "3xhkhx": "highPrecedence(\"2*2\");", - "4143lf": "initialize buttons" + "4143lf": "initialize buttons", + "y1f9p0": "for (let i = 1; i <= count; i++) {\n rows.push(padRow(i, count));\n}", + "697fln": "while (rows.length < count) {\n rows.push(padRow(rows.length + 1, count));\n}", + "499lw3": "for (let i = count; i > 0; i--) {\n rows.push(padRow(i, count));\n}" } diff --git a/curriculum/dictionaries/english/comments.json b/curriculum/dictionaries/english/comments.json index e888013dc3b..39cd3ae9fca 100644 --- a/curriculum/dictionaries/english/comments.json +++ b/curriculum/dictionaries/english/comments.json @@ -108,5 +108,6 @@ "es69h6": "When you join two windows into one window", "fho5t5": "When you open a new tab at the end", "00kcrm": "yields true", - "sxpg2a": "Your mailbox, drive, and other work sites" + "sxpg2a": "Your mailbox, drive, and other work sites", + "n4f332": "TODO: use a different type of loop" }